This project has moved and is read-only. For the latest updates, please go here.

Is MagickImage thread safe for reading?

Mar 19, 2015 at 3:08 PM
I need to put watermark image on different images on the fly in multithreaded environment ( website). Instead of loading MagickImage for watermark each time and use it in image.Composite I wanted to load it once and store in static field. So is MagickImage thread safe for read operation (I don't think Composite modifies the source image)?
Mar 19, 2015 at 6:20 PM
Reading from a MagickImage is thread safe. You can do the following without any problems:
using (MagickImage watermark = new MagickImage(@"C:\watermark.png"))
  Parallel.ForEach(Directory.GetFiles(@"c:\input", "*.png"), (string fileName) =>
    using (MagickImage image = new MagickImage(fileName))
      image.Composite(watermark, CompositeOperator.Over);
Mar 20, 2015 at 6:15 AM
Edited Mar 20, 2015 at 7:15 AM
Thank you!