1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-26 07:14:31 +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

@@ -275,9 +275,18 @@ class Image
// create new image
$image = imagecreatetruecolor($dst_w, $dst_h);
// preserve transparency
imagealphablending($image, false);
imagesavealpha($image, true);
// preserve transparency
$transIndex = imagecolortransparent($this->resource);
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
imagecopyresampled(