Conversion of 12 x 36 inch 300 dpi 100 images performance

Aug 31, 2015 at 9:45 AM
Hi. Thanks for providing us support here. We are using vb.net to do the following:
  1. Take 100 images of size 12in x 36in and 300dpi and we want to do some color adjustments.
  2. Check and resize all images to be as above specs.
  3. Split into half and save again.
Here is my code:
    Dim currentimage As Integer = 0
    For Each img In imgarray
        '2. Apply settings to this image
        Using mgkImage As New MagickImage(imgarray(currentimage).ToString)
            mgkImage.BrightnessContrast(brightnessval, 0)
            mgkImage.BrightnessContrast(0, contrastval)
            mgkImage.Fx("u-" & cyanval.ToString, Channels.Red)
            '3. Save the image
            mgkImage.Write(DataValues.savepath & Path.GetFileName(mgkImage.FileName))
        End Using
        currentimage += 1
        saveFileprogress.Value = (currentimage / imgarray.Count) * 100
    Next
Now it takes 30 minutes to process 60 jpg files. Can we use Parallel.For or something you suggest to increase the speed and performance.

Moreover we need to check the resolution/dpi of each image also and if not 300, we need to make it exactly 12in x 36in and 300dpi.
Coordinator
Aug 31, 2015 at 10:20 AM
You are working with pixels in Magick.NET. What are the dimensions of your input images? Are they really 13392x40622? Are some of the input images bigger then that size or will you make your source image larger?

What does split into half and save again mean?

You can use a Parallel.For but Magick.NET already has some multi-threading optimizations so you will have to test for yourself which one works better.

Why do your images need to be 300 DPI?
Aug 31, 2015 at 12:52 PM
Edited Aug 31, 2015 at 12:52 PM
Images are to print on Digital and Offset machines. So final output has to be 300dpi PDF.
  1. Images resolution = 12 * 300 X 36 * 300. That means 3600 X 10800 pixels. This will be maximum size restricted. So we don't need to bother about more heavy image.
  2. Split into half means divide 12in x 36in to two 12in x 18in images and save separately.
Coordinator
Aug 31, 2015 at 3:22 PM
You are right, my dimensions calculation is wrong. But that means you will be working with really big images and that will take a lot of time.

I would also advise you to use mgkImage.Evalute to set the red channel. This method is faster then the Fx method.

And I am a bit confused now what you are trying to ask me. You seem to know the answers to your own questions. Can you clarify what is unclear to you?
Aug 31, 2015 at 8:09 PM
I need to speed up the process of setting channel values.

Kindly give me an example of using Parallel For for my array of images, and also i was unable to use Evaluate to reduce red values. Say I have to reduce 10 points of red as per photoshop Color balance. How to do it using Evaluate. Also it needs to be fast. What can be done.
Coordinator
Sep 1, 2015 at 11:10 AM
You can reduce the value of the red channel like this:
mgkImage.Evaluate(Channels.Red, EvaluateOperator.Subtract, 10);
The 10 is probably not correct because I don't know what '10 points' means.

And you can find some help about writing a Parallel for loop here: https://msdn.microsoft.com/en-us/library/dd460713(v=vs.110).aspx