6

I recently upgraded from 2.4.4 to 2.4.5. While placing the images in pub/media folder and running bin/magento catalog:images:resize, I am getting the following error

imagecolorsforindex(): Argument #2 ($color) is out of range#0 /var/www/html/vendor/magento/framework/Image/Adapter/Gd2.php(347): imagecolorsforindex(Object(GdImage), 48)

Any idea what went wrong and how to rectify it ?

enter image description here

edit : It seems PHP GD Library gives error if Color went out of range. https://www.php.net/manual/en/function.imagecolorsforindex.php.

so index 48 is out of range, in previous version this returned false but now it throws error. I had checked the view.xml, but still can't figure out the issue.

1

3 Answers 3

9

vendor/magento/framework/Image/Adapter/Gd2.php around line 346:

-        if ($transparentIndex >= 0 && $transparentIndex <= imagecolorstotal($this->_imageHandler)) {
+        if ($transparentIndex >= 0 && $transparentIndex < imagecolorstotal($this->_imageHandler)) {
1
  • yes working for me Thanks @Konstantin G. Commented Feb 15 at 7:50
6

I did a workaround and it seems to work (not the actual solution).

I basically changed the default image adapter configuration of "Image Processing Settings" in Configuration>Advanced>Developer>Image Processing Settings from PHP GD2 to ImageMagick, and ran catalog:images:resize again after flushing image cache. This is a PHP GD2 library issue and no one had reported it yet.

2

this also works to solve the infinite scroll issue related to this error

Magento2 Error: "Something went wrong with processing the default view and we have restored the filter to its original state"

this link shows temp fixes for error mentioned driectly above

Magento2 Error: "Something went wrong with processing the default view and we have restored the filter to its original state" showing on the loop

What I did

enabled dev mode, then changed the image processing to imagick, now back to prod mode.

This solved the load issue This created ability to enter larger custom qty amounts in per page view of catalog/products page in magento 2.4.4 running php 8.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.