Skip to content

Commit 45e8278

Browse files
authored
Merge pull request #5971 from kenjis/fix-GDHandler-save-transparency
fix: GDHandler::save() removes transparency
2 parents 10ae2d4 + d177fd6 commit 45e8278

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

system/Images/Handlers/GDHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ public function save(?string $target = null, int $quality = 90): bool
225225

226226
$this->ensureResource();
227227

228+
// for png and webp we can actually preserve transparency
229+
if (in_array($this->image()->imageType, $this->supportTransparency, true)) {
230+
imagealphablending($this->resource, false);
231+
imagesavealpha($this->resource, true);
232+
}
233+
228234
switch ($this->image()->imageType) {
229235
case IMAGETYPE_GIF:
230236
if (! function_exists('imagegif')) {

0 commit comments

Comments
 (0)