Magento2: catalog:images:resize = getimagesize(): Read error! in vendor/magento/module-catalog/Model/Product/Image.php on line 410 if an image is 0 bytes

Created on 19 Jan 2017  路  6Comments  路  Source: magento/magento2

When I attempt to execute:
php bin\magento catalog:images:resize

After a period of time, I receive this error:

Notice: getimagesize(): Read error! in /vendor/magento/module-catalog/Model/Product/Image.php on line 410

However, no report is pushed into any log file, so there is no way to find out the file causing the read error.

After some digging I realized its due to images that have a zero byte size (I use a 3rd party image upload tool that will upload zero byte files (ticket is open with them as well)

Luckily, I upload all of my files from a single image directory, so I was able to identify the offending file, but many won't be this lucky.

Preconditions


  1. Magento 2.1.3
  2. PHP 7
  3. nginx - hosted server

Steps to reproduce

  1. Upload a file into a product, make sure its a zero byte file, and make it the image/thumbnail/small reference.
  2. go to the command line, and execute php bin\magento catalog:images:resize
  3. after a period of time, the above error will appear.

Expected result

  1. It should just skip the offending file, and/or update the log file to indicate which/where the problematic file resides.
Catalog Fixed in 2.2.x Clear Description Confirmed Format is not valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x bug report

Most helpful comment

I got the same problem on 2.3.2 as well. Ran this command to find and delete files with 0 bytes:

find <Magento root/pub/media/ -type f -size 0 | xargs rm -f

All 6 comments

@spyrule Thanks for reporting this issue.
We've created internal ticket MAGETWO-63599 to address this issue.

@spyrule, thank you for your report.
We've created internal ticket(s) MAGETWO-63599 to track progress on the issue.

I'm working on it #SQUASHTOBERFEST

Hi @spyrule
The issue has been fixed and delivered in 2.2-develop branch. Will be available with upcoming patch release.

Hi ... Is this fixed? Because I can see it is still happening with me on 2.3.2.
In my case i have just migrated from 1.9 to 2.3.2

I got the same problem on 2.3.2 as well. Ran this command to find and delete files with 0 bytes:

find <Magento root/pub/media/ -type f -size 0 | xargs rm -f

Was this page helpful?
0 / 5 - 0 ratings