You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Imagick driver writes white image after resize #1261
Describe the bug
I have a large JPEG file which results in a white output file (with correct dimensions) after resizing. If I use Imagick directly from within PHP it works correctly (at least with the thumbnailImage method). Also when using the GD-driver, the results are as expected.
After more fiddling, even leaving the resize call out of it, results in a white image, see code sample below.
Code Example
Expected behavior
I expect the st-john2.jpg to have the same file size and content. Instead the original is ~25MB and the new version ~180kB
Images
I can provide the image using PB, due to copyright.
After some more digging, this problem doesn't occur when removing line Intervention\Image\Drivers\Imagick\Decoders\BinaryImageDecoder::32
The coalesceImages() call causes the image to become empty/white.
The question now is, is this a InterventionImage bug, or an Imagick bug. Or is the image corrupt...
A possible fix could be to replace line 32, but I cannot oversee if this would break stuff. I did a quick test resizing an animated GIF and the image mentioned in the start post.
I updated my previous message, because I missed your reply:
The coalesceImages() call causes the image to become empty/white.
The question now is, is this a InterventionImage bug, or an Imagick bug. Or is the image corrupt...
A possible fix could be to replace line 32, but I cannot oversee if this would break stuff. I did a quick test resizing an animated GIF and the image mentioned in the start post.
After further tests, I currently see no other possibility than to call coalesceImages() only for animated images all image formats except Jpeg. Because Jpeg has no transparency and can not be animated.
Although I cannot understand the logic of this error at all.
It could very well be a bug in ImageMagick. This could even be fixed with ImageMagick >= 7.1.1-24, as no error occurred with this version in my tests. However, this is just speculation and would have to be checked.
Activity
storeman commentedon Jan 10, 2024
After some more digging, this problem doesn't occur when removing line
Intervention\Image\Drivers\Imagick\Decoders\BinaryImageDecoder::32The
coalesceImages()call causes the image to become empty/white.The question now is, is this a InterventionImage bug, or an Imagick bug. Or is the image corrupt...
A possible fix could be to replace line 32, but I cannot oversee if this would break stuff. I did a quick test resizing an animated GIF and the image mentioned in the start post.
olivervogel commentedon Jan 10, 2024
That's strange. I just checked it with the image from the URL in my environment and could not reproduce the problem described.
Everything ok
PHP: 8.2.14
Host OS: Mac OS 13
Intervention Image Version: 3.2.3
Imagick 3.7.0 / ImageMagick 7.1.1-24 Q16-HDRI aarch64 21856
olivervogel commentedon Jan 10, 2024
I checked it again on Debian. Here I can see the effect with the white background. Unfortunately, that doesn't get me any further at the moment.
Bug reproducable
PHP: 8.1.26
Host OS: Debian
Intervention Image Version: 3.2.3
Imagick 3.7.0 / ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25
Bug reproducable
PHP: 8.2.14
Host OS: Debian
Intervention Image Version: 3.2.3
Imagick 3.7.0 / ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25
storeman commentedon Jan 10, 2024
Thanks Oliver for checking.
I updated my previous message, because I missed your reply:
Basically this checks if coalesceImages() does anything. If not, continue working with the original.
olivervogel commentedon Jan 10, 2024
After further tests, I currently see no other possibility than to call
coalesceImages()only foranimated imagesall image formats except Jpeg. Because Jpeg has no transparency and can not be animated.Although I cannot understand the logic of this error at all.
It could very well be a bug in ImageMagick. This could even be fixed with ImageMagick >= 7.1.1-24, as no error occurred with this version in my tests. However, this is just speculation and would have to be checked.
Fix decoding error with Imagick driver
olivervogel commentedon Jan 14, 2024
This issue should be kept in mind. The described bug was only fixed with a workaround and a more permanent solution should be sought.
See: 1e4afd5
Fix decoding error with Imagick driver