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:
@@ -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(
|
||||||
|
Reference in New Issue
Block a user