Re: [PHP] imagecreatefromgif & imagecolortransparent() ??



Here's a code snippet from the php.net documentation on
imagecolortransparent by Blaine Ehrhart

<?php
$im = imagecreatefromgif('trans.gif');
$img = imagecreatetruecolor(16,16);
$trans = imagecolorallocate($img,255,99,140);
imagecolortransparent($img,$trans);
imagecopy($img,$im,0,0,0,0,16,16);
imagetruecolortopalette($img, true, 256);
imageinterlace($img);
imagegif($img,'trans.gif');
imagedestroy($img);
?>

See if it works.

On Thu, Dec 4, 2008 at 10:44 AM, LucaP <lucapost@xxxxxxxxx> wrote:

Hi all, the simple code snippet:

header('Content-type: image/gif');
$im = imagecreatefromgif("/path/Mypic.gif");
$background = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im,$background);

imagegif($im,'/path/TransparentPic.gif');
imagedestroy($im);


is creating the new image but is not setting the white background to
transparent;
I am sure about the presence of the white color in the background
(checked it with imagecolorat() etc).

a similarly simple test setting transparency on a new image created
with 'imagecreatetruecolor()' works correctly... any hints?!

Cheers, Luca

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

.