diff --git a/system/Images/Handlers/GDHandler.php b/system/Images/Handlers/GDHandler.php index ab8e0b7e3dd3..b05084d273a1 100644 --- a/system/Images/Handlers/GDHandler.php +++ b/system/Images/Handlers/GDHandler.php @@ -225,6 +225,12 @@ public function save(?string $target = null, int $quality = 90): bool $this->ensureResource(); + // for png and webp we can actually preserve transparency + if (in_array($this->image()->imageType, $this->supportTransparency, true)) { + imagealphablending($this->resource, false); + imagesavealpha($this->resource, true); + } + switch ($this->image()->imageType) { case IMAGETYPE_GIF: if (! function_exists('imagegif')) {