I am trying to set the temporary directory used by ImageMagick to convert files. Currently, when converting large PDF files, the temporary folder quickly reaches 2 or 3 terabytes. It is too much to store servers on disk, so I plan to use AWS EFS to store everything. I have an EFS drive installed in /efsand am trying to use it for a temporary path.
How can I install this in ImageMagick? I tried the following:
- Setting PHP temp upload folder in php.ini - it debugs files and does not work
- Modifying the ImagickMagick config.xml file that does not work.
- Adding an environment variable
MAGICK_TMPDIR=/efs - Adding an environment variable
MAGICK_TEMPORARY_PATH=/efs
No matter what I do, it is always converted to a folder /tmp. How can I install this?
Is it different because it's PHP? Apparently in the command line version you can do this:
convert -define registry:temporary-path=/Volumes/external/tmp
My current PHP code is this, I was wondering if there is a function to install tmp dir here? Like a thing $imagick->setTmpDir('/efs'). I searched the PHP API and cannot find a way to do this.
$imagick = new Imagick();
$imagick->setResourceLimit( Imagick::RESOURCETYPE_MEMORY, 5 );
$imagick->setResolution(600,600);
$imagick->setCompressionQuality(100);
$imagick->readImageBlob($file);
$imagick->deskewImage(40);
$imagick->setImageFormat('jpg');
$imagick->writeImages(storage_path("app/docs/".$doc->id.".jpg"), false);
Any ideas? I have been doing this for several days!
Ubuntu Server
source
share