Closed UFMurphy closed 2 years ago
Found resolution.
What solution did you find?
@nocturnalpollinator ..
I changed this line (line 71 in vendor/league/color-extractor/src/League/ColorExtractor/Palette.php)
if (!is_resource($image) || get_resource_type($image) != 'gd')
to this line:
if (!($image instanceof \GdImage) && (!is_resource($image) || get_resource_type($image) != 'gd')) {
Hey guys,
I am doing some tutorials on composer and one of the lessons uses the color-extractor package. All seems to install ok. But I keep getting an error when I try to stream in an image.
This code block seems to cause an issue (line 54-55 - vendor/league/color-extractor/src/League/ColorExtractor/Palette.php):
$image = imagecreatefromstring(file_get_contents($filename));
$palette = self::fromGD($image, $backgroundColor);
As does this one (line 71 same file):
if (!is_resource($image) || get_resource_type($image) != 'gd')
The condition gets met and we see the following error.
Fatal error: Uncaught InvalidArgumentException: Image must be a gd resource in /Users/ufmurphy/Sites/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php:72 Stack trace: #0 /Users/ufmurphy/Sites/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php(55): League\ColorExtractor\Palette::fromGD(Object(GdImage), NULL) #1 /Users/ufmurphy/Sites/index.php(19): League\ColorExtractor\Palette::fromFilename('images/bricks.j...') #2 {main} thrown in /Users/ufmurphy/Sites/vendor/league/color-extractor/src/League/ColorExtractor/Palette.php on line 72
Doing some sleuthing, it looks like a change in how GD images are handled in PHP8. https://php.watch/versions/8.0/gdimage
Is there a more recent version than 0.3.2?
Thanks, Jim