problem with transparent Image

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

problem with transparent Image

Postby sneha1234 » Mon Sep 29, 2008 7:12 am

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....
sneha1234
Forum Newbie
 
Posts: 5
Joined: Mon Sep 29, 2008 2:36 am

Re: problem with transparent Image

Postby vishal.angre » Wed Oct 01, 2008 6:23 am

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);
vishal.angre
Forum Newbie
 
Posts: 9
Joined: Wed Oct 01, 2008 4:32 am
Location: Mumbai, India

Re: problem with transparent Image

Postby onion2k » Wed Oct 01, 2008 6:56 am

Where in that code will it be making the image transparent?
User avatar
onion2k
Jedi Mod
 
Posts: 5263
Joined: Tue Dec 21, 2004 6:03 pm
Location: usrlab.com


Return to PHPGD.com

Who is online

Users browsing this forum: No registered users and 2 guests