1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 15:24:37 +02:00

preserving transparency on palette images

This commit is contained in:
Oliver Vogel
2013-11-06 21:06:40 +01:00
parent b88450a325
commit cb8d377258

View File

@@ -276,8 +276,17 @@ class Image
$image = imagecreatetruecolor($dst_w, $dst_h); $image = imagecreatetruecolor($dst_w, $dst_h);
// preserve transparency // preserve transparency
imagealphablending($image, false); $transIndex = imagecolortransparent($this->resource);
imagesavealpha($image, true);
if ($transIndex != -1) {
$rgba = imagecolorsforindex($image, $transIndex);
$transColor = imagecolorallocate($image, $rgba['red'], $rgba['green'], $rgba['blue']);
imagefill($image, 0, 0, $transColor);
imagecolortransparent($image, $transColor);
} else {
imagealphablending($image, false);
imagesavealpha($image, true);
}
// copy content from resource // copy content from resource
imagecopyresampled( imagecopyresampled(