cancel
Showing results for 
Search instead for 
Did you mean: 

Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Hi there,

Recently I have migrated the magento-1 (ver: 1.9.1.1) data to magento-2 (Ver: ver: 2.1.2) fress version using data migration tool. And it working perfectly in our local computer (localhost).

I found an issue after upload it to server m2.hiddencamera.com.au that some product images not showing instead it showing blank image (http://m2.hiddencamera.com.au/hidden-cameras?cat=84). And this problem is for not generating the image cache in pub/media/catalog/product/cache/ folder.

But when I try to regenerate the image using php bin/magento catalog:image:resize it showing a warning;

Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file in /vendor/magento/framework/Image/Adapter/Gd2.php on line 65

However in the mean time before showing the Warning it generate some new images cache in the /pub/media/catalog/product/cache folder.

I have tried to show the new generated images after setup:upgrade, indexer:reindex, cache:clean, cache:flush But it not updating the image url for the new generated images cache.

 

Also I have contacted with the hosting support (siteground) but no luck.

Additional Information

  • Upgraded M2 Ver: 2.1.2
  • Migrated from: 1.9.1.1
  • PHP Version: 7.0.21
  • memory_limit: 768M
  • max_execution_time: 120

N.B: I have checked after migrated the Magento1 data to Magento ver: 2.1.7 that it causing the same issue when upload to server, but working properly in localhost.

 

I don't know exactly where the problem is. Please help me to resolve the issue for regenerating the product images.

Regards,

5 REPLIES 5

Re: Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

I am also facing the same issue. 

Re: Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Found a temporary solution

replace your code 

call_user_func($this->_getCallback('create'), $this->_fileName);

to 

@call_user_func($this->_getCallback('create'), $this->_fileName);

 in vendor/magento/framework/Image/Adapter/Gd2.php line 65  

Re: Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Hi @PKRay @shoeb_shukoor

You can try below php_ini setting in index.php.

ini_set ('gd.jpeg_ignore_warning', 1);



Re: Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Did it work for you?

Re: Warning: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file

Hello,

 

I am getting the same issue, I followed both the solution but no luck. Can anyone help me on this please ?