cancel
Showing results for 
Search instead for 
Did you mean: 

Some images could not be resized after server migration

Some images could not be resized after server migration

Hi,

 

I am getting the following error every time I try to add a new image. If I set the new image to hidden, before saving my product, the image get saved.

Capture.PNG

This Magento store was upgraded from Magento 1.9 to mag 2.2.6 but it is working fine on the website I did the upgrade, I did it on another server with a different domain. After I migrated everything to the new server, an AWS EC2 server running Ubuntu with all the server requirements listed on the Magento website, I did the following:

 

- migrated all the data to MySQL

- Migrated all the files and corrected the file permissions

- I did run the following:

php bin/magento setup:di:compile (just in case)

php bin/magento setup:static-content:deploy es_ES -f

php bin/magento setup:static-content:deploy -f (for the English lang)

php bin/magento indexer:reindex

php bin/magento cache:clean

php bin/magento cache:flush

 

I disabled cache and enabled it again, but nothing works. As I said above, everything works fine on my other server. I did updated the PHP configuration, reinstalled php, used the same version of php, nothing works.

 

Here is the system.log error that it is showing when I try to save a product with an image

 

This is the error on my var/log/system.log file:

[2019-07-23 23:40:02] main.ERROR: The image could not be resized: /home/ServerUser/public_html/pub/media/catalog/product/h/i/hidrolavadora_t50_1.jpg [] []
[2019-07-23 23:40:02] main.ERROR: Notice: Undefined index: dirname in /home/ServerUser/public_html/vendor/magento/framework/Image/Adapter/AbstractAdapter.php on line 520 [] []
[2019-07-23 23:40:02] main.ERROR: The image could not be resized: /home/ServerUser/public_html/pub/media/catalog/product/h/i/hidrolavadora_t50_1.jpg [] []
[2019-07-23 23:40:02] main.ERROR: Notice: Undefined index: dirname in /home/ServerUser/public_html/vendor/magento/framework/Image/Adapter/AbstractAdapter.php on line 520 [] []
[2019-07-23 23:40:02] main.ERROR: The image could not be resized: /home/ServerUser/public_html/pub/media/catalog/product/h/i/hidrolavadora_t50_1.jpg [] []
[2019-07-23 23:40:02] main.ERROR: Notice: Undefined index: dirname in /home/ServerUser/public_html/vendor/magento/framework/Image/Adapter/AbstractAdapter.php on line 520 [] []
[2019-07-23 23:40:02] main.ERROR: The image could not be resized: /home/ServerUser/public_html/pub/media/catalog/product/h/i/hidrolavadora_t50_1.jpg [] []
[2019-07-23 23:40:02] main.CRITICAL: Exception message: Some images could not be resized. See log file for details.
Trace: #0 /home/ServerUser/public_html/vendor/magento/module-catalog/Model/Product.php(957): Magento\Catalog\Model\Product\Image\Cache->generate(Object(Magento\Catalog\Model\Product\Interceptor))
#1 /home/ServerUser/public_html/vendor/magento/framework/EntityManager/Observer/AfterEntitySave.php(31): Magento\Catalog\Model\Product->afterSave()
#2 /home/ServerUser/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(72): Magento\Framework\EntityManager\Observer\AfterEntitySave->execute(Object(Magento\Framework\Event\Observer))
#3 /home/ServerUser/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(60): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod(Object(Magento\Framework\EntityManager\Observer\AfterEntitySave), Object(Magento\Framework\Event\Observer))
#4 /home/ServerUser/public_html/vendor/magento/framework/Event/Manager.php(66): Magento\Framework\Event\Invoker\InvokerDefault->dispatch(Array, Object(Magento\Framework\Event\Observer))
#5 /home/ServerUser/public_html/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch('magento_catalog...', Array)
#6 /home/ServerUser/public_html/vendor/magento/framework/EntityManager/EventManager.php(52): Magento\Framework\Event\Manager\Proxy->dispatch('magento_catalog...', Array)
#7 /home/ServerUser/public_html/vendor/magento/framework/EntityManager/Operation/Update.php(110): Magento\Framework\EntityManager\EventManager->dispatchEntityEvent('Magento\\Catalog...', 'save_after', Array)
#8 /home/ServerUser/public_html/vendor/magento/framework/EntityManager/EntityManager.php(96): Magento\Framework\EntityManager\Operation\Update->execute(Object(Magento\Catalog\Model\Product\Interceptor), Array)
#9 /home/ServerUser/public_html/vendor/magento/module-catalog/Model/ResourceModel/Product.php(655): Magento\Framework\EntityManager\EntityManager->save(Object(Magento\Catalog\Model\Product\Interceptor))
#10 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Catalog\Model\ResourceModel\Product->save(Object(Magento\Catalog\Model\Product\Interceptor))
#11 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Model\ResourceModel\Product\Interceptor->___callParent('save', Array)
#12 /home/ServerUser/public_html/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Product.php(51): Magento\Catalog\Model\ResourceModel\Product\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Product\Interceptor))
#13 /home/ServerUser/public_html/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Product.php(24): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product->addCommitCallback(Object(Magento\Catalog\Model\ResourceModel\Product\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Product\Interceptor))
#14 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Product\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Product\Interceptor))
#15 /home/ServerUser/public_html/vendor/magento/framework/App/Cache/FlushCacheByTags.php(68): Magento\Catalog\Model\ResourceModel\Product\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Product\Interceptor))
#16 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Product\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Product\Interceptor))
#17 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\ResourceModel\Product\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Product\Interceptor))
#18 /home/ServerUser/public_html/generated/code/Magento/Catalog/Model/ResourceModel/Product/Interceptor.php(39): Magento\Catalog\Model\ResourceModel\Product\Interceptor->___callPlugins('save', Array, Array)
#19 /home/ServerUser/public_html/vendor/magento/framework/Model/AbstractModel.php(647): Magento\Catalog\Model\ResourceModel\Product\Interceptor->save(Object(Magento\Catalog\Model\Product\Interceptor))
#20 /home/ServerUser/public_html/vendor/magento/module-catalog/Controller/Adminhtml/Product/Save.php(111): Magento\Framework\Model\AbstractModel->save()
#21 /home/ServerUser/public_html/vendor/magento/framework/App/Action/Action.php(107): Magento\Catalog\Controller\Adminhtml\Product\Save->execute()
#22 /home/ServerUser/public_html/vendor/magento/module-backend/App/AbstractAction.php(235): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#23 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->___callParent('dispatch', Array)
#25 /home/ServerUser/public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#26 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#27 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#28 /home/ServerUser/public_html/generated/code/Magento/Catalog/Controller/Adminhtml/Product/Save/Interceptor.php(26): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->___callPlugins('dispatch', Array, NULL)
#29 /home/ServerUser/public_html/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Product\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#30 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#31 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#32 /home/ServerUser/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#33 /home/ServerUser/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#34 /home/ServerUser/public_html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#35 /home/ServerUser/public_html/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http->launch()
#36 /home/ServerUser/public_html/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#37 {main} [] []
7 REPLIES 7

Re: Some images could not be resized after server migration

Hello @Elm6r 

 

Please follow below steps:

1. Set mode to developer so it will not through any notice error: php bin/magento deploy:mode:set developer

2. Set folder permissions: sudo chmod -R 0777 var/ pub/

3. Flush cache using this: php bin/magento cache:flush php bin/magento cache:clean

4. Run command to to resize images: php bin/magento catalog:images:resize

when running this command, Magento2 will not create another image size if one already exists in the image cache.

 

Please follow these steps and let me know still if there any issues. Thanks

Manish Mittal
https://www.manishmittal.com/

Re: Some images could not be resized after server migration

Hi,

I followed y our instructions, but the problem is not with the command

php bin/magento catalog:images:resize

When I run that command, it finishes without problem. My problem is when I go to the Catalog > Products

Then I edit a product which has a few images, then I hit the Save button and it give the error I mentioned above.

 

Also happens when I create a new product and upload a new image, it doesn't matter what the extension the image has, it always shows the same error.

 

 

Re: Some images could not be resized after server migration

Hello @Elm6r 

 

If all fine then you can try to run below commands and then try again if it works:

 

rm -Rf var/cache/*
rm -Rf var/page_cache/*

Or can read this article if it helps you:

https://www.ctidigital.com/blog/fixing-image-resize-issues-after-upgrading-to-magento-2.1.6 

Manish Mittal
https://www.manishmittal.com/

Re: Some images could not be resized after server migration

Thanks for sharing

Re: Some images could not be resized after server migration

@lori_brown 

 

It works for you?

Manish Mittal
https://www.manishmittal.com/

Re: Some images could not be resized after server migration

yes

Re: Some images could not be resized after server migration

Hello @lori_brown 

 

Great! Let us know if you need any assistance further. 

Manish Mittal
https://www.manishmittal.com/