Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imager X fails with low ImageMagick limits #169

Open
1 of 3 tasks
dgsiegel opened this issue Sep 12, 2022 · 0 comments
Open
1 of 3 tasks

Imager X fails with low ImageMagick limits #169

dgsiegel opened this issue Sep 12, 2022 · 0 comments

Comments

@dgsiegel
Copy link

I'm submitting a...

  • bug report
  • feature request
  • general question

Steps to reproduce

  1. Set up a transformation for a volume with plenty of transformations
  2. Use ImageMagick as Image drive
  3. Transform images in a volume and see some images fail

Description

Unfortunately our hosting provider set quite low ImageMagick limits (/etc/ImageMagick-6/policy.xml):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policymap [
  <!ELEMENT policymap (policy)*>
  <!ATTLIST policymap xmlns CDATA #FIXED ''>
  <!ELEMENT policy EMPTY>
  <!ATTLIST policy xmlns CDATA #FIXED '' domain NMTOKEN #REQUIRED
    name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED
    stealth NMTOKEN #IMPLIED value CDATA #IMPLIED>
]>
<policymap>
  <policy domain="resource" name="memory" value="256MiB"/>
  <policy domain="resource" name="map" value="512MiB"/>
  <policy domain="resource" name="width" value="16KP"/>
  <policy domain="resource" name="height" value="16KP"/>
  <policy domain="resource" name="area" value="128MP"/>
  <policy domain="resource" name="disk" value="1GiB"/>
</policymap>

Our transforms are set up like this

<?php

return [
  'p' => [
    'transforms' => [
      ['width' => 576],
      ['width' => 768],
      ['width' => 992],
      ['width' => 1200],
      ['width' => 1400],
      ['width' => 1680],
      ['width' => 1920],
    ],
  ],
];

Our pregenerate config like this

<?php

return [
  'volumes' => [
    'press'   => ['p'],
  ],
];

When running /craft imager-x/generate -v press --interactive 0 we get the following error message in console.log:

2022-09-12 12:55:24 [-][-][-][error][spacecatninja\imagerx\transformers\CraftTransformer::getTransformedImage] An error occured when trying to open image: Unable to open image /nfs/web_mwn/www/2/***/webserver/htdocs/assets/press/Bild7.jpg

Looking further into the exception, I can find this message:

[...]
    [previous:Exception:private] => ImagickException Object
        (
            [message:protected] => cache resources exhausted `/nfs/web_mwn/www/2/klk1102/webserver/htdocs/assets/press/Bild7.jpg' @ error/cache.c/OpenPixelCache/4095
            [string:Exception:private] =>
            [code:protected] => 445
            [file:protected] => /nfs/web_mwn/www/2/klk1102/webserver/vendor/pixelandtonic/imagine/src/Imagick/Imagine.php
            [line:protected] => 69
[...]

So it seems that this transformation hits the ceiling of the 256MiB memory limit and fails.

Using fewer transformations, like the following seems to work (but is obviously not our goal):

<?php

return [
  'p' => [
    'transforms' => [
      ['width' => 576],
      ['width' => 768],
    ],
  ],
];

Also, setting instanceReuseEnabled to true reduces the amount of failing images, but does not work for all. Switching to GD as image driver also seems to do the trick.

Here's one example of a failing image:
Bild7

Additional info

  • Imager version & edition: v3.6.3.1 Pro
  • Imager transformer: craft
  • Craft version: 3.7.53.1
  • PHP version: 8.0.20
  • Image driver & version: Imagick 3.6.0 (ImageMagick 6.9.11-60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant