I'm trying to run ImageMagick without touching the filesystem: image data is read from memory/the network, and written back to a socket as a blob.
However, ImageMagick continually tries to write temp files, which either fill up my test system due to aborted/failed tests, or cause problems on systems with extremely slow disks: it's a weird constraint, but many of my conversion hosts are embedded-like systems with block devices that are extremely slow to respond to any operations, even stat()
s.
Questions:
Is there a way to configure ImageMagick to not touch the disk during image processing?Assume that all required modules that ImageMagick will use have already been loaded, and that none of the ImageMagick functionality that farms processing out to subprocesses that talk to the filesystem will be used.
What are the side effects of doing this? I'm OK with processing that won't fit in memory failing, rather than falling back to the disks.
I'm converting using the C++ or Perl ImageMagick APIs, not the convert
utility. If another binding has support for this, though, I'm fine switching platforms.
What I've Tried
- I've set the
MAGICK_TEMPORARY_PATH
to various places, including/dev/null
on POSIX./dev/null
sometimes seems to work, but my target systems aren't POSIX, so I'm not sure if I can count on it. Rather than fooling the temp file management system, I'd prefer something that I can trust to disable the need for temp files in the first place. - I've used the
registry:temporary-path
option, with similar results. - Setting the various temporary path options to nonexistent/unusable locations (e.g.
/dev/null
or a non-writable location) often seems to result in temporary files being created in the directory from which my program is launched. If that directory is non-writable, I have seen temp files get created in the system/tmp
directory even if the code was told not to use it. These seem to happen in exceptional cases (e.g. segfaulting/OOMing/kill -9
'd situations), so I gather that files may be created in these places normally, but are usually cleaned up.