Page 1 of 1

multi-threading with libjpeg

Posted: 2007-03-21T08:08:53-07:00
by phireph0x
we're developing a network app using the Magick++ interface that reads several *.jpg images from disk from multiple separate threads. Even though ImageMagick has been compiled statically with multi-threading support on Win32, we notice when we step through the code that threading is being disabled for JPEGs (libjpeg), so the images are being read from disk in a non-threaded fashion. Is this intentional, or should libjpeg be thread-safe?

perusing the ImageMagick site docs, it seems that the claim is made that ImageMagick is thread-safe with the exception of a few select pixel cache related functions, which we don't use in our code..

Is ImageMagick thread-safe for libjpeg, or is multi-threading disabled because of thread-safety issues with libjpeg?

Re: multi-threading with libjpeg

Posted: 2007-03-21T13:00:51-07:00
by magick
ImageMagick is thread safe, the JPEG delegate library is not. You can enable thread support by editing coders/jpeg.c and changing the thread support member to this:
  • entry->thread_support=DecoderThreadSupport | EncoderThreadSupport;
in the RegisterJPEGImage() method.

Re: multi-threading with libjpeg

Posted: 2007-03-21T14:06:08-07:00
by phireph0x
thanks for the info.

if the delegate library, libjpeg, is not thread-safe, then i'd rather not enable threading, overriding the defaults, if the results will be unstable.

is there an alternative delegate library for the jpeg coder, or is no multi-threading support simply a fact of life when dealing with JPEGs and ImageMagick?