When using ImageMagick, I can set certain limits for memory usage and maximum number of threads. There are 3 ways to do this, as far as I know:
- use a command line options like "convert -limit memory 128mb original.jpg new.jpg"
- use environment variables like "MAGICK_THREAD_LIMIT=1"
- edit the 'policy.xml' configuration file to change the default value.
I have tested each of these methods using "convert -list resource" and they work.
Now, I need to use the IMagick extension in PHP. There is a function I can use to set limits:
bool Imagick::setResourceLimit (int $type, int $limit)
For the first parameter I can use one of the following:
imagick::RESOURCETYPE_AREA (integer) //equivalent of MAGICK_AREA_LIMIT
imagick::RESOURCETYPE_DISK (integer) //equivalent of MAGICK_DISK_LIMIT
imagick::RESOURCETYPE_FILE (integer) //equivalent of MAGICK_FILE_LIMIT
imagick::RESOURCETYPE_MAP (integer) //equivalent of MAGICK_MAP_LIMIT
imagick::RESOURCETYPE_MEMORY (integer) //equivalent of MAGICK_MEMORY_LIMIT
The problem is that there is no equivalent for MAGICK_THREAD_LIMIT and IMagick seems to simply ignore the configuration files and the environment variables. How do I know this? I've set all the memory limits to zero and IMagick still functions without any problem when it should report insufficient memory.
I really hope I have made myself clear. The question is: how can I change the thread limit when using IMagick?
Thank you in advance.
EDIT: I've managed to set the thread limit to 1 by compiling ImageMagick with the '--without-threads' option. :P It will have to do until I find a better solution.