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:
@@ -276,8 +276,17 @@ class Image
|
||||
$image = imagecreatetruecolor($dst_w, $dst_h);
|
||||
|
||||
// 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(
|
||||
|
Reference in New Issue
Block a user