dynamic
dynamic

Reputation: 48141

Imagick::resizeImage vs Imagick::scaleImage

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?

Upvotes: 22

Views: 17920

Answers (3)

Uday Hiwarale
Uday Hiwarale

Reputation: 233

According to my finding, when you want to scale down an image, use resizeImage. Because It gives you control over image quality and type of filter you want to use. But in the same case, scaleImage is also a good choice because when you have to scale down an image to let's say by factor of 10 and you are using resizeImage, then your resulting image will have many graphical errors.

In second case, when you have to scale up and image, then resizeImage will definetely have graphical error like while marks and lines and other stuff. In that case, scaleImage will come to rescue.

Upvotes: 0

Yuri
Yuri

Reputation: 2028

Brilliant, their own documentation is awful... But ok: It looks to me like resizeImage is more powerful, and therefore the better choice... This link shows the usage along with some measurements for different filters.

Upvotes: 1

Pekka
Pekka

Reputation: 449683

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.

Upvotes: 22

Related Questions