I have a GIF with a transparent background. I then use some PHP to copy a section of it out. The transparent regions then turn black.

//variables are all properly defined elsewhere

$target_id = imagecreatetruecolor($dest_x, $dest_y);
$target_pic = imagecopyresampled($target_id,$source_id_original, 0, 0, 0, 0, $dest_x, $dest_y, $size[0],$size[1]);
$thumblink = $thumb_dir.$prefix.$name;
if (ereg("\.gif$", $name))
{
	$source_id = imagegif($target_id,$thumblink, $quality);
	$source_id_original = imagecreatefromgif($thumblink);
}
    Shawazi wrote:

    I have a GIF with a transparent background. I then use some PHP to copy a section of it out. The transparent regions then turn black.

    //variables are all properly defined elsewhere
    
    $target_id = imagecreatetruecolor($dest_x, $dest_y);
    $target_pic = imagecopyresampled($target_id,$source_id_original, 0, 0, 0, 0, $dest_x, $dest_y, $size[0],$size[1]);
    $thumblink = $thumb_dir.$prefix.$name;
    if (ereg("\.gif$", $name))
    {
    	$source_id = imagegif($target_id,$thumblink, $quality);
    	$source_id_original = imagecreatefromgif($thumblink);
    }
    

    Yeah, resizing does that.

    what you have to do is get any one transparent pixel from the original

    & then use imagecolortransparent() on the new one

    http://www.php.net/manual/en/function.imagecolortransparent.php

      So I have to use that function before I use imagecopyresampled?

        Write a Reply...