Skip to content

Commit ae252ab

Browse files
authored
Merge pull request #145 from Sybio/fix-issue-144
Fix ImageWorkshopLib::generateImage when using transparent background
2 parents 0c18211 + 7be211a commit ae252ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Core/ImageWorkshopLib.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ public static function convertHexToRGB(?string $hex): array
7979
*/
8080
public static function generateImage(int $width = 100, int $height = 100, string $color = 'ffffff', int $opacity = 127): GdImage
8181
{
82-
$RGBColors = ImageWorkshopLib::convertHexToRGB($color);
83-
8482
$image = imagecreatetruecolor($width, $height);
8583
imagesavealpha($image, true);
84+
85+
if ($color === 'transparent') {
86+
$color = 'ffffff';
87+
$opacity = 127;
88+
}
89+
90+
$RGBColors = ImageWorkshopLib::convertHexToRGB($color);
8691
$color = imagecolorallocatealpha($image, $RGBColors['R'], $RGBColors['G'], $RGBColors['B'], $opacity);
92+
8793
imagefill($image, 0, 0, $color);
8894

8995
return $image;

0 commit comments

Comments
 (0)