2

I installed imagemagick following instructions from Why is ImageMagick with OpenCL slower than OpenMP?. I need to resize an image to 4 different sizes and have to crop them. I wrote a C++ program that calls image.resize("500x500!"), image.resize("550x550!"), image.resize("600x600!"), image.resize("650x650!"), image.crop(Geometry(200,150, 10,50)) for 100 images in a folder.

When I run the same case in command line like this :

cd /home/Downloads/ImageMagick-6.9.3-7/utilities/ && \
    exec sudo time ./convert img.jpg -write \
     mpr:scroll  -filter Lanczos -resize 500x500 -crop 200x150+10+50 -write m.jpg delete \
     mpr:scroll  -filter Lanczos -resize 600x600 -crop 200x150+10+50 -write n.jpg delete \                 
     mpr:scroll  -filter Lanczos -resize 550x550 -crop 200x150+10+50 -write o.jpg delete \ 
     mpr:scroll  -filter Lanczos -resize 650x650 -crop 200x150+10+50 p.jpg;

I got an output in 8124.13ms. But when I did the same case in Magick++ API, I got an output in 369237 ms. Why is there this much difference?

When I check the device benchmark file as this :

$ cat ~/.cache/ImageMagick/ImagemagickOpenCLDeviceProfile

it shows

<version>ImageMagick Device Selection v0.9</version>
<device><type></type><name>Quadro M6000</name><driver>352.79</driver><max cu>24</max cu><max clock>1114</max clock><score>0.0960</score></device>
<device><type></type><score>1.1890</score></device>

According to the post in How do I build ImageMagick with OpenCL?, the API has to run in GPU, because GPU device is having minimum score. How can I resolve it?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Vanns
  • 159
  • 7
  • Can you re-benchmark with 512x512(to 256x256) and 640x640 sized images please? – huseyin tugrul buyukisik Apr 05 '16 at 12:16
  • @huseyintugrulbuyukisik API, 512x512 to 256x256 -> 20169.9ms, 640x640 to 256x256 -> 24032.8ms. In Command Line, 512x512 to 256x256 -> 1520.79ms, 640x640 to 256x256 -> 2364.57ms – Vanns Apr 05 '16 at 12:45
  • I meant with Magick++ API against that 369 second version. – huseyin tugrul buyukisik Apr 05 '16 at 12:54
  • @huseyintugrulbuyukisik that 369237ms is for Magick API only.. For command line i got 8124ms – Vanns Apr 05 '16 at 13:03
  • "-resize is supported, but not -thumbnail nor -sample. When the difference of size between the original and the thumbnail is large, -sample helps make -thumbnail faster than -resize. Testing should answer whether the speed penalty of doing the "proper" resize is compensated by the faster hardware." is said in https://phabricator.wikimedia.org/T107752 – huseyin tugrul buyukisik Apr 05 '16 at 13:07
  • @huseyintugrulbuyukisik yeah.. in my case it is working well. but my question is why this difference in time between api call and command line? time has to be more or less same for api call and command line. – Vanns Apr 05 '16 at 13:19
  • Are you sure that you are not re-reading the image each time? – dlemstra Apr 05 '16 at 18:53
  • @dlemstra ya i m not re-reading the image – Vanns Apr 06 '16 at 05:28

0 Answers0