MG 1.1 Error when rebuilding XMG Thumbnails

sami simo

Well-known member
When trying to rebuild XenForo Media Gallery Thumbnails, I get this error:

Server Error

memory allocation failed `/home//public_html/internal_data/temp/xfmgll6Mkd' @ error/gif.c/WriteGIFImage/1623

Imagick->writeimage() in XenGallery/Helper/Image.php at line 280
XenGallery_Helper_Image->resize() in XenGallery/Deferred/Thumbnail.php at line 60
XenGallery_Deferred_Thumbnail->execute() in XenForo/Model/Deferred.php at line 295
XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 429
XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 374
XenForo_Model_Deferred->run() in XenForo/ControllerAdmin/Tools.php at line 159
XenForo_ControllerAdmin_Tools->actionRunDeferred() in XenForo/FrontController.php at line 347
XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
XenForo_FrontController->run() in //public_html/admin.php at line 13
 
The PECL Imagick extension/ImageMagick failed to allocate memory. This might indicate that you're out of memory or that there's a limitation on the amount of memory your process can allocate. Does it happen every time?
 
I should add that this option doesn't perform particularly well:
upload_2016-1-15_22-58-35.webp
If you have this option enabled, disable it, and see if the process finishes successfully.
 
I get similar error when trying to remove addons:
An exception occurred: memory allocation failed `/home//public_html/internal_data/temp/xfmg2w93dd' @ error/gif.c/WriteGIFImage/1623 in /home//public_html/library/XenGallery/Helper/Image.php on line 280

Imagick->writeimage() in XenGallery/Helper/Image.php at line 280
XenGallery_Helper_Image->resize() in XenGallery/Deferred/Thumbnail.php at line 60
XenGallery_Deferred_Thumbnail->execute() in XenForo/Model/Deferred.php at line 295
XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 429
XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 374
XenForo_Model_Deferred->run() in XenForo/ViewRenderer/Abstract.php at line 352
XenForo_ViewRenderer_Abstract::hasManualDeferredToRun() in XenForo/ViewRenderer/HtmlAdmin.php at line 50
XenForo_ViewRenderer_HtmlAdmin->renderRedirect() in XenForo/FrontController.php at line 612
XenForo_FrontController->renderView() in XenForo/FrontController.php at line 158
XenForo_FrontController->run() in /home//public_html/admin.php at line 13

Now, I cant uninstall any addon in my forum, any idea?
 
Sorry I neglected to reply to this sooner.

Uninstalling an add-on will add some more deferred processes to run, but first it will try to complete the existing ones and the thumbnail one hasn't finished yet, hence the error.

In the first instance, I suggest removing the thumbnail rebuild entry from the xf_deferred table, this will allow you to continue anything else you need to do.
(Using phpMyAdmin, go to the xf_deferred table and delete the record that has a class of "XenGallery_Deferred_Thumbnail")

Secondly, if you go to your Admin CP <your_url>/admin.php?tools/phpinfo what is your memory_limit setting? It may be worth increasing this and restarting PHP/the webserver to see if it makes a difference.

Incidentally, this actually could be a bug. On upload we bail out of thumbnail creation under certain conditions, we may well not be checking those conditions when rebuilding thumbnails.
 
Thanks Chris, the memory limit in phpinfo is : 512M.
is this is too small? if yes, I will try to increase it, I prefer to do that rather than touching any database table.
 
512M is actually pretty big.

If there's enough physical memory on the server, it wouldn't hurt to increase it but only temporarily.

If it still doesn't work, please return the memory limit back to what it was and then start a ticket from your customer area and provide FTP access. It would be interesting to ascertain which image is causing this.
 
Well, this makes very little sense, so far.

The images it falls over on are in a certain category (link in ticket). They are all single frame gifs that are actually quite small; around 500 x 500 px. The interesting fact is that of course the images are about 18 months old and were uploaded and thumbnailed at some point in the past and they obviously didn't error out then.

It's not uncommon for the imagick module or Image Magick itself to have bugs. The imagick module you have installed is version 3.1.2 (which is quite old, circa 2013) and the Image Magick build itself is from 2011 I think. PHP is up to date. It might be worth updating the imagick module and the Image Magick application itself to see if it makes a difference. If the images were originally uploaded on this server, something has changed since then (the code itself hasn't). Judging by the age of the imagick stuff, it may well be that the only thing that has changed is the PHP build, so my only feasible assumption so far is an incompatibility with newer PHP and older imagick stuff.

@MattW if this is possible, please let us know how you get on.

I managed to get the thumbnail rebuild (and the rebuild caches from your add-on install/uninstall) done by skipping the problematic images. For now, I've commented this skip out of the code (so the problem currently still exists). If upgrading imagemagick doesn't help, then you can uncomment the "continue" line from the following code in library/XenGallery/Deferred/Thumbnail.php and those image files will be skipped:
PHP:
            if (in_array($item['media_id'], [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38]))
            {
                //continue;
            }
 
It's not uncommon for the imagick module or Image Magick itself to have bugs. The imagick module you have installed is version 3.1.2 (which is quite old, circa 2013) and the Image Magick build itself is from 2011 I think. PHP is up to date. It might be worth updating the imagick module and the Image Magick application itself to see if it makes a difference. If the images were originally uploaded on this server, something has changed since then (the code itself hasn't). Judging by the age of the imagick stuff, it may well be that the only thing that has changed is the PHP build, so my only feasible assumption so far is an incompatibility with newer PHP and older imagick stuff.

@MattW if this is possible, please let us know how you get on.
Imagick was installed via the built in RPM function in cPanel. If those images were added 18 months ago, that's well before they were hosted on my servers. This is a shared server, so I can't really go rebuilding stuff ad-hoc :(
 
Top Bottom