D
D
devAston2019-09-25 10:38:06
PHP
devAston, 2019-09-25 10:38:06

How to fix "cache resources exhausted" problem of imagick library in PHP 7.3?

Good afternoon, colleagues!

Initial data

Имеется Docker с web-приложением внутри на PHP7.3-apache;
Изображение "ORIGINAL" с разрешением 7500x10500px в формате tiff и размером 149 Мб.
Тестовое изображение "MIDDLE" с разрешением 7600x7600px в формате tiff (LZW сжатие) и размером 8.9 Мб.
Тестовое изображение "LARGE" с разрешением 11000x11000px в формате tiff (LZW сжатие) и размером 14.9 Мб.

There is a script for image processing

$img = new Imagick();
$img->readImage(Storage::path($filePath.$fileName));
$img->setImageFormat('png');
...
$img->writeImage(public_path($fileName));
$img->destroy();

There is no problem when executing the script with the image " MIDDLE ", but when using [" ORIGINAL " and " LARGE "] "cache resources exhausted `/var/www/html/storage/app/upload/image-tiff/2019-09 arrives -39/LARGE_f2ed11af1f6bbbccdeb621eb4a843b02.tiff' @ error/cache.c/OpenPixelCache/4083"
Initial resource limits:
Imagick::RESOURCETYPE_MEMORY = 268435456
Imagick::RESOURCETYPE_MAP = 536870912
Imagick::RESOURCETYPE_AREA = 128000000
Imagick::RESOURCETYPE_DISK = 1073741824

If you set these limits at least 1 unit higher, it resets to the original values.
for example

Imagick::setResourceLimit(Imagick::RESOURCETYPE_MEMORY, 1024435456);
Imagick::setResourceLimit(imagick::RESOURCETYPE_MAP, 1536870912);
Imagick::setResourceLimit(IMagick::RESOURCETYPE_AREA , 256000000);
Imagick::setResourceLimit(IMagick::RESOURCETYPE_DISK , 4073741824);


I will be grateful for the description of the solution to my problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question