Imagick::resizeImage vs Imagick::scaleImage

dynamic picture dynamic · Mar 12, 2011 · Viewed 15.7k times · Source

What are the differences between resizeImage and scaleImage?

I need to resize an image if its size is > $myLimit

Example (pseudocode):

$myLimit = 1MB
user uplaod an image of 1000x1000 of 2MB
2MB > $myLimit
while( $imagefilesize > $myLimit  ) {
  resizeImageBy 0.9%;
}

//> output 900x900 image of 900 kB

In the while block, which of the two methods should I use?

Edit: I found something that could help: http://www.imagemagick.org/Usage/resize/ But could someone simplify that?

Answer

Pekka picture Pekka · Mar 12, 2011

The difference between the two seems to be that scaleImage does a raw, pixel based resize, while resizeImage can use an interpolation filter:

imagick::INTERPOLATE_AVERAGE
imagick::INTERPOLATE_BICUBIC
imagick::INTERPOLATE_BILINEAR
...

that is likely to produce better results.

More on the various interpolation methods on Wikipedia.