hi!
i m facing the Problem, i want transparent image of some width n height and text on that image...but when i m using
imageSaveAlpha($image, true);
ImageAlphaBlending($image, false); its not working...
so i had another code...
<?php
Header('Content-type: image/png');
//$size = 300;
//$Img=imagecreatetruecolor(100,30);
$Img = imagecreate(110,30);
$Gray = imagecolorallocatealpha($Img, 0, 0, 255, 10);
$text = 'Testing..';
imageFilledRectangle($Img,0,0,100,100,$Gray);
imagecolortransparent($Img,$Gray);
$font = 'Shelley_AllegroScript.ttf';
imagettftext($Img, 20, 0, 10, 20, $Gray, $font, $text);
//imagestring($Img,4,0,0,$text,$Gold);
//imagecolortransparent($Img,$Gray);
imagepng($Img);
ImageDestroy($Img);
?>
but i m getting diminished text....
problem with transparent Image
Moderators: onion2k, General Moderators
-
vishal.angre
- Forum Newbie
- Posts: 11
- Joined: Wed Oct 01, 2008 4:32 am
- Location: Mumbai, India
Re: problem with transparent Image
Use this code..
$text = "Testing..";
// create the image
// use white as the background image
$image = imagecreate(100, 30);
$bgColor = imagecolorallocate($image, 255, 255, 255);
// the text color is black
$textColor = imagecolorallocate($image, 192, 82, 67);
// write the random number
imagestring ($image, 5, 5, 8, $text, $textColor);
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/png');
// send the image to the browser
imagepng($image);
// destroy the image to free up the memory
imagedestroy($image);
$text = "Testing..";
// create the image
// use white as the background image
$image = imagecreate(100, 30);
$bgColor = imagecolorallocate($image, 255, 255, 255);
// the text color is black
$textColor = imagecolorallocate($image, 192, 82, 67);
// write the random number
imagestring ($image, 5, 5, 8, $text, $textColor);
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// send the content type header so the image is displayed properly
header('Content-type: image/png');
// send the image to the browser
imagepng($image);
// destroy the image to free up the memory
imagedestroy($image);
Re: problem with transparent Image
Where in that code will it be making the image transparent?