Hi all,
Under PHP 4.3.10 I am using imagecopyresampled to generate a thumbnail from a larger image.
With gif files I wish to preserve transparency which I thought I had cured but only certain parts of the image are being made transparent even though the transparent pixel is present throughout the image.
Here is the code I use :-
$the_image = imagecreatefromstring($image_data);
if ($image_type == "image/gif") {
$idx_src = imagecolortransparent($the_image);
$rgb_values = imagecolorsforindex($the_image, $idx_src);
}
$thumb = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($thumb, $the_image, 0, 0, 0, 0, $new_width, $new_height, $current_width, $current_height);
if ($image_type == "image/gif") {
$idx_target = imagecolorallocate($thumb, $rgb_values['red'], $rgb_values['green'], $rgb_values['blue']);
imagefill($thumb, 0, 0, $idx_target);
imagecolortransparent($thumb, $idx_target);
}
imagegif($thumb);
Can anyone see where I am going wrong? The gifs are always 216 colour palettes with a single transparent pixel usually white or black.