Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.79k stars 1.5k forks source link

Reading a very large image with Imagick results in error "Unable to decode input" #1357

Closed hetao29 closed 1 month ago

hetao29 commented 1 month ago

Describe the bug If the image file is huge(17.4MB, 9952 x 14032), then error : vendor/intervention/image/src/Drivers/AbstractDecoder.php(38) 0:Unable to decode input

Code Example

$mgr = Intervention\Image\ImageManager::imagick();// ::gd() is OK.
$img = $mgr->read("/tmp/large.jpg");

Environment (please complete the following information):

How to set setresourcelimit https://www.php.net/manual/en/imagick.setresourcelimit.php

olivervogel commented 1 month ago

Thanks for reporting. There is currently no way to call this method with this library. I will look into this, how this could be solved.

olivervogel commented 1 month ago

I think the best way is to do this configuration outside of this library for Imagick directly in the policy.xml.

Something like this.

<policymap>
  <policy domain="resource" name="memory" value="256MB"/>
  <policy domain="resource" name="map" value="512MB"/>
  <policy domain="resource" name="disk" value="1GB"/>
  <policy domain="resource" name="file" value="768"/>
  <policy domain="resource" name="thread" value="1"/>
</policymap>

See Imagick Documentation for further details.