使用 `--without-threads` 选项的 ImageMagick 线程安全吗?

Is ImageMagick thread safe with `--without-threads` option?

我使用多线程通过 ImageMagick 加载图像。配置 --without-threads 选项安全吗?

来自 ImageMagick.org 上的论坛 post -- "thread safe ?":

ImageMagick is thread safe, we perform thousands of tests before a release with and without valgrind.

此 post 还包括 ImageMagick 使用的示例单元测试

另一个post -- "What do I lose by disabling threads?":

ImageMagick works fine without threads. However, a number of the ImageMagick language wrappers ... assume a threaded environment and their applications will crash and burn when they call ImageMagick methods from more than one thread of execution. With threads enabled, ImageMagick applies numerous mutex locks to serialize the splay-tree, hash, list methods, generating Wand ids, etc.

来自第三个post "--disable-thread confusion":

ImageMagick is thread safe but some coder modules are not (e.g. JPEG). If a coder modules is not thread safe we serialize access to the module with our own mutexes. More recent versions of ImageMagick distinguish coder module thread support for reading and writing (some modules are threaded when reading an image but not for writing or vise versa).

因此,共识似乎是 ImageMagick 使用 --without-threads 仍然在很大程度上是线程安全的,其结果是执行速度较慢,并且某些包装器、库或模块可能不是线程安全的(因此 "crash and burn")。

直接回答您关于多线程阅读的问题,但这取决于您使用的库——例如,如果您使用的是 JPEG 委托库,它不是线程安全的(来源如下) ).

libjpeg.txt:

Note: the JPEG library currently is not thread-safe.