Page 1 of 1

Setting MAGICK_TMPDIR environment variable programatically?

Posted: 2007-06-04T05:16:04-07:00
by sacha
Using ImageMagick-6.2.8

ImageMagick on UNIX relies on the environment variables MAGICK_TMPDIR or TMPDIR to work out where to put temporary files.

I have ImageMagick embedded in a larger program which reads this location from a configuration file for its own purposes. It's not practical to set it in the environment before the program is run.

Is there a way in the C API to set ImageMagick's temporary directory? (Looking at the 6.2.8 code I can't see that there is, so I guess this is as much a feature request as a question!)

setenv() is not portable.

Re: Setting MAGICK_TMPDIR environment variable programatically?

Posted: 2007-06-04T06:38:18-07:00
by magick
Try this:
  • putenv("MAGICK_TMPDIR=/data");

Re: Setting MAGICK_TMPDIR environment variable programatically?

Posted: 2007-06-05T08:54:05-07:00
by sacha
Indeed I've resolved this by using putenv(). Note though that it isn't portable either; Windows has a _putenv() with slightly different semantics, so I've had to write a (simple) wrapper.

It would still be nice for this to be abstracted by the ImageMagick API.