I am using im4java in my project for various image processing techniques such as cropping, resizing, filling and rotating. Before this I was using the java.lang.Runtime.exec
to run commands in the command prompt. Now when I bench marked the two methods, they almost gave the same result! I don't need the parallel processing feature of the im4java
, because the output of one process is the input of the other, hence sequential. In my case, it provides just one advantage: ease of use. And that's all.
Do you think I am missing something or lacking somewhere in my code? Any suggestions would be of great help. Thanks in advance!
Yes, you are right that using im4java along only gives you the same performance as you did with Runtime.exec. Or maybe slower because it has the command building and translation layer.
But if your applicaiton is to convert a lot of images in one run (or large scale concurrent processing), then please let me shamelessly introduce the gm4java, which can help to improve the performance.
gm4java makes use of recently developed batch/interactive mode of GraphicsMagick to aovid starting a new GraphicsMagick process again and again for every command. It can be used as supplement to im4java or just execute the command you built for your Runtime.exec.