Closed Mark-H closed 3 years ago
What happens if you execute the following code:
$pngContent = hex2bin('89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c4890000000a49444154789c63000100000500010d0a2db40000000049454e44ae426082');
var_dump((new \Imagine\Gd\Imagine())->load($pngContent));
var_dump(imagecreatefromstring($pngContent));
On 7.4.12:
object(Imagine\Gd\Image)[45]
private 'resource' => resource(237, gd)
private 'layers' => null
private 'palette' =>
object(Imagine\Image\Palette\RGB)[42]
private 'parser' =>
object(Imagine\Image\Palette\ColorParser)[41]
private 'profile' => null
protected 'metadata' =>
object(Imagine\Image\Metadata\MetadataBag)[43]
private 'data' =>
array (size=0)
empty
private 'classFactory' (Imagine\Image\AbstractImage) =>
object(Imagine\Factory\ClassFactory)[48]
resource(245, gd)
On 8.0.2:
object(Imagine\Gd\Image)#55 (5) {
["resource":"Imagine\Gd\Image":private]=>
object(GdImage)#54 (0) {
}
["layers":"Imagine\Gd\Image":private]=>
NULL
["palette":"Imagine\Gd\Image":private]=>
object(Imagine\Image\Palette\RGB)#43 (2) {
["parser":"Imagine\Image\Palette\RGB":private]=>
object(Imagine\Image\Palette\ColorParser)#47 (0) {
}
["profile":"Imagine\Image\Palette\RGB":private]=>
NULL
}
["metadata":protected]=>
object(Imagine\Image\Metadata\MetadataBag)#44 (1) {
["data":"Imagine\Image\Metadata\MetadataBag":private]=>
array(0) {
}
}
["classFactory":"Imagine\Image\AbstractImage":private]=>
object(Imagine\Factory\ClassFactory)#50 (0) {
}
}
object(GdImage)#55 (0) {
}
When feeding that the test file it gives the same result (resource on 7.4.12, GdImage on 8.0.2).
(Also, thanks for responding so quickly, and on the weekend too!)
Okay so running that test code had me super confused, as it was suddenly allowing to load() the same image that would continue to fail as part of my upload code.
After some more digging, it turns out the upload code ran into a dependency conflict. An older version of another addon in the same CMS installation was loading imagine v1.2.3, and that got used in the upload code. But not when I ran the test code from a different file. 🙈
So - bottom line - it was a problem on this end and fixed with v1.2.4. Thanks for the quick support!
Issue description
Provided the raw binary contents of the same image, the following works on 7.4.12, but on 8.0.2 throws an exception:
What version of Imagine are you using?
v1.2.4
What's the PHP version you are using?
Fails on:
with GD config:
Works as expected on:
with GD config:
On localhost powered by MAMP Pro, macOS 11.3.
What's the imaging library you are using [gd/imagick/gmagick/any]?
GD
What's the imaging library configuration
Included above
Minimal PHP code to reproduce the error:
$imageContent is provided from a file upload and read into memory in its binary form (basically a glorified file_get_contents on the upload file, though there's some abstraction going on that also allows it to work on S3 and such).
I've compared the output of
bin2hex($imageContent)
on both PHP versions which are identical, so it doesn't seem to be an issue with loading the file contents. But I'm not sure how to debug this from here.Removing the metadata reader does not have any effect.
This is the test image I was using, but it seems to affect all images I try it with.