Setting MAGICK_TMPDIR environment variable programatically?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sacha

Setting MAGICK_TMPDIR environment variable programatically?

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Setting MAGICK_TMPDIR environment variable programatically?

Post by magick »

Try this:
  • putenv("MAGICK_TMPDIR=/data");
sacha

Re: Setting MAGICK_TMPDIR environment variable programatically?

Post 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.
Post Reply