Closed DrewBold closed 2 years ago
Hi,
The check that fails uses Craft's internal function for calculating if enough memory has been allocated in PHP to transform an image based on its width, height and color depth. It's not a very complex calculation, so one of the following is the issue:
1) The memory_get_usage
method is disabled in PHP
2) Information about the image was not possible to get using getimagesize
, which could mean that there isn't support for the image format in PHP.
3) Or, the image was just too large to be transformed with the PHP configuration.
If this works in your local environment, and you're testing with the same assets, it's unlikely to be 3). I'd maybe look into 1) and 2), it could for instance be that you're trying to transform an image that's in webp or avif format, and the dev server doesn't have support for that?
In the above code, what's photo
? If it's an Asset, it's much better to just pass that into craft.imager.transformImage
directly, since passing in the URL will treat it as an external image.
HI Thank you for your reply.
I was able to to determine the cause of the issue. It was a corrupted cache file for imager-x.
Not sure how this occurred as it was fine before we purchased the license and then occurred after...perhaps an interrupted queue job? Regardless once I manually cleared everything for imager-x in the ./storage/runtime - the transforms were working again.
Thanks again!
I'm submitting a...
Steps to reproduce
Description
This is working on my local(mac / MAMP) with a memory limit of 1024M. However it is not working on our dev server (linux/linode nginx) with a memory_limit of 8GB
PASTE THE ERROR MESSAGE / STACK TRACE HERE spacecatninja\imagerx\exceptions\ImagerException: Not enough memory available to perform this image operation. in /var/www/craft_elc_dev/vendor/spacecatninja/imager-x/src/transformers/CraftTransformer.php:202 Stack trace:
0 /var/www/craft_elc_dev/vendor/spacecatninja/imager-x/src/transformers/CraftTransformer.php(96): spacecatninja\imagerx\transformers\CraftTransformer->getTransformedImage(Object(spacecatninja\imagerx\models\LocalSourceImageModel), Array)
1 /var/www/craft_elc_dev/vendor/spacecatninja/imager-x/src/services/ImagerService.php(472): spacecatninja\imagerx\transformers\CraftTransformer->transform('https://www.exp...', Array)
2 /var/www/craft_elc_dev/vendor/spacecatninja/imager-x/src/variables/ImagerVariable.php(38): spacecatninja\imagerx\services\ImagerService->transformImage('https://www.exp...', Array, NULL, NULL)
3 /var/www/craft_elc_dev/vendor/twig/twig/src/Extension/CoreExtension.php(1566): spacecatninja\imagerx\variables\ImagerVariable->transformImage('https://www.exp...', Array)
4 /var/www/craft_elc_dev/vendor/craftcms/cms/src/helpers/Template.php(106): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(spacecatninja\imagerx\variables\ImagerVariable), 'transformImage', Array, 'method', false, false)
5 /var/www/craft_elc_dev/storage/runtime/compiled_templates/07/071090a7bc43397ab2e0c9e87d5b9094d33807e89fa049fb240c8f8bdfb44f6e.php(218): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(spacecatninja\imagerx\variables\ImagerVariable), 'transformImage', Array, 'method')
6 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(405): __TwigTemplate_1cdd48a8949f2d0ac15bf739b823d6a2beea6ca04b3374a45a5a784bbccb76ed->doDisplay(Array, Array)
7 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
8 /var/www/craft_elc_dev/storage/runtime/compiled_templates/b3/b320e5a57515cbc52d5892940b758fc2ebad77ffeb42fb90ad95d734e3d1de12.php(107): Twig\Template->display(Array)
9 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(182): __TwigTemplate_56759be0fbebc0f71b9136b5e87866783175830d4b3f9a2dc88c9fc3151bae2b->block_content(Array, Array)
10 /var/www/craft_elc_dev/storage/runtime/compiled_templates/ba/ba0ad576663a99170b281fee5d82554c8d52ade9140711f299622f9100603e6d.php(66): Twig\Template->displayBlock('content', Array, Array)
11 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(182): __TwigTemplate_e7482cc45c72e5ee3eee71ada404fe99b75eba1ad59b2914e63150ed58a85b7e->block_body(Array, Array)
12 /var/www/craft_elc_dev/storage/runtime/compiled_templates/c0/c0cb7178bce98b8b6c09e3a58302f373ead45bd9e944ca03e0dae36d171627b0.php(278): Twig\Template->displayBlock('body', Array, Array)
13 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(405): __TwigTemplate_be147b9bcfc6c1d6305fa7b7f585617263015cae4e6ff57db85aaf071883b476->doDisplay(Array, Array)
14 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
15 /var/www/craft_elc_dev/storage/runtime/compiled_templates/ba/ba0ad576663a99170b281fee5d82554c8d52ade9140711f299622f9100603e6d.php(44): Twig\Template->display(Array, Array)
16 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(405): __TwigTemplate_e7482cc45c72e5ee3eee71ada404fe99b75eba1ad59b2914e63150ed58a85b7e->doDisplay(Array, Array)
17 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
18 /var/www/craft_elc_dev/storage/runtime/compiled_templates/b3/b320e5a57515cbc52d5892940b758fc2ebad77ffeb42fb90ad95d734e3d1de12.php(60): Twig\Template->display(Array, Array)
19 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(405): __TwigTemplate_56759be0fbebc0f71b9136b5e87866783175830d4b3f9a2dc88c9fc3151bae2b->doDisplay(Array, Array)
20 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
21 /var/www/craft_elc_dev/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
22 /var/www/craft_elc_dev/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
23 /var/www/craft_elc_dev/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
24 /var/www/craft_elc_dev/vendor/craftcms/cms/src/web/View.php(408): Twig\Environment->render('_entries/_categ...', Array)
25 /var/www/craft_elc_dev/vendor/craftcms/cms/src/web/View.php(461): craft\web\View->renderTemplate('_entries/_categ...', Array)
26 /var/www/craft_elc_dev/vendor/craftcms/cms/src/web/Controller.php(205): craft\web\View->renderPageTemplate('_entries/_categ...', Array, 'site')
27 /var/www/craft_elc_dev/vendor/craftcms/cms/src/controllers/TemplatesController.php(102): craft\web\Controller->renderTemplate('_entries/_categ...', Array)
28 [internal function]: craft\controllers\TemplatesController->actionRender('_entries/_categ...', Array)
29 /var/www/craft_elc_dev/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
30 /var/www/craft_elc_dev/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
31 /var/www/craft_elc_dev/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('render', Array)
32 /var/www/craft_elc_dev/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('templates/rende...', Array)
33 /var/www/craft_elc_dev/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
34 /var/www/craft_elc_dev/vendor/craftcms/cms/src/web/Application.php(278): yii\web\Application->handleRequest(Object(craft\web\Request))
35 /var/www/craft_elc_dev/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
36 /var/www/craft_elc_dev/web/index.php(12): yii\base\Application->run()
37 {main}
Additional info
Imager version & edition: v3.6.5
Imager transformer: 'optimizers' => ['jpegtran', 'optipng', 'gifsicle'],
Craft version: Craft Pro 3.7.59
PHP version: 7.3.31
Image driver & version: