Skip to content

Commit

Permalink
Adjust logic of cloner transparency application
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Aug 11, 2024
1 parent 7a9bb78 commit 6a4607d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Drivers/Gd/Cloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Intervention\Image\Drivers\Gd;

use GdImage;
use Intervention\Image\Colors\Rgb\Channels\Alpha;
use Intervention\Image\Colors\Rgb\Color;
use Intervention\Image\Exceptions\ColorException;
use Intervention\Image\Geometry\Rectangle;
Expand Down Expand Up @@ -67,7 +68,9 @@ public static function cloneEmpty(
imagealphablending($clone, true);
imagesavealpha($clone, true);

if ($background->isClear()) {
// set background image as transparent if alpha channel value if color is below .5
// comes into effect when the end format only supports binary transparency (like GIF)
if ($background->channel(Alpha::class)->value() < 128) {
imagecolortransparent($clone, $processor->colorToNative($background));
}

Expand Down

0 comments on commit 6a4607d

Please sign in to comment.