0

We use GM to do image compressing, and observe a significant performance difference between zoom and sample functions, which we suppose to do the same thing.

When using zoom function for a 68k image, a process could consume all the cpu time for all cores(12 core, 2.4G Hz machine), the throughput is 65/seconds, response time is 469 ms on average, load by top command is around 11, cpu usage is close to 100%

When using sample function in the same environment, 24 process work together providing throughput close to 1000/seconds, response time is 37 ms on average, load by top command is around 3, cpu usage fluctuates between 50% and 80%

the official document for these two functions is very simple as below:

sample Resize image by using pixel sampling algorithm:

void sample ( const Geometry &geometry_ )

zoom Zoom (resize) image to specified size:

void zoom ( const Geometry &geometry_ )

the effects after the image processing are similar, but the difference is huge.

  1. Could anyone explain the different circumstances of using these two functions, since we might choose sample over zoom because of the performance issue

  2. Further, could anyone tell me why zoom is so cpu-time-consuming.

Chen Yi
  • 171
  • 1
  • 6
  • After comparing the images processed by zoom and sample, we found 1. image processed by zoom has better quality than image processed by sample. 2 zoom provided by imagemagick is much faster or less cpu-time-consuming than zoom provided by graphicmagick. Consequently, we decided to use zoom provided by imagemagick. – Chen Yi Nov 01 '12 at 03:28

1 Answers1

0

Since there was less performance with GraphicsMagick, perhaps there was some system-dependent issue like cache line thrashing. The -sample option uses simple point sampling in which each point in the output image selects one point from the input image. The -zoom option does horizontal/vertical filtering using a specified filter (-filter) so it provides high quality (depending on the filter). For really large images I recommend using -scale which is a windowed filter which produces results almost as good as -zoom but using only one CPU core and still quite fast.

Bob Friesenhahn
  • 306
  • 1
  • 5