How many colours in your image?  Don't forget that GD can only handle
8-bit colour.

-Rasmus

On Mon, 22 Jan 2001, Niklas Saers wrote:

> Hi. I'm afraid I have to say that the transparency in PHP with GD doesn't
> seem to work. Let me give you an example. The included file, midblob.png, has
> a transparent area where the color is #bcbcad. Take a look at the
> following code:
>
> if(!isset($text)) $text="Remember to define \$text";
> $font = 5;
> $size = GetImageSize("midblob.png"); // 0=x, 1=y
> $buffer= Array(5,(($size[1]-ImageFontHeight($font))/2)-3);
> $width=(ImageFontWidth($font)*strlen($text))+($buffer[0]*2)-1;
> $if = ImageCreateFromPNG ("midblob.png"); /* Attempt to open */
> $im=ImageCreate($width,$size[1]);
> $resize = ImageCopyResized($im,$if,0,0,0,0,$width,$size[1],$size[0],$size[1]);
> $colal = ImageColorAllocate($im,0xbc,0xbc,0xad);
> $trans = ImageColorTransparent($im,$colal);
> $tc  = ImageColorAllocate ($im, 255, 255, 255);
> ImageString ($im, $font, $buffer[0], $buffer[1], $text,$tc);
> header ("Content-type: image/png");
> ImagePng ($im);
>
> Now, the line $colal = ...  and $trans = ... shouldn't be necessary because
> it already has a transparent region. However, ImagePng doesn't seem to output
> this transparently, but rather as #cccc99. Putting in these two lines doesn't
> help either. Now, this is really strange. PNG has transparency, and the loaded
> image does. Why doesn't ImagePng output the transparancy right?
>
> Cheers
>
>
>  Niklas Saers
>
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to