Page 1 of 1

resize vs resample, which compression and which filter :S

Posted: 2007-07-22T20:38:29-07:00
by DJTurboToJo
Hello,

I m writing a program that reads a directory and then makes for each jpg file a thumbnail and a resized picture in 640x480. Everything should be only for use on the computer.

I m pretty new and now I was searching too long without getting any useful information.

Ok, so I read the image and then

Code: Select all

MagickThumbnailImage(magick_wand,w,h);
creates nice and small thumbnails.

But then come the problems:
1. resizing vs. resampling
I read a lot on the Internet about it but I m still confused. Please correct me if I misunderstood anything: With Resizing some pixel are deleted/duplicates so that the new picture got the new pixel size. I'm not sure what Resampling really does. According to http://www.retouchpro.com/forums/glossa ... ample.html the pixel size doesnt change. However, if I do resampling with a picture to get 72dpi (I found that this should be the best resolution for monitors) my picture changes its pixel size. I had a picture that was 2253x1690 and so

Code: Select all

MagickResampleImage(magick_wand, 72, 72, CatromFilter,1.0);
it became 901x676. If I resampled this new 901x676 picture into 72 again (so actually nothing should change) the pixel size was reduced again. Ok that didnt help with my confusion so I read more http://studio.imagemagick.org/pipermail ... 15237.html: There it is said that any change in the resolution (dpi or ppi) doesnt change the pixel size.

EDIT: Ok so now I know a bit more. My picture has a resolution of 180x180 and even if I resample this into 72 with

Code: Select all

MagickResampleImage(magick_wand, 72, 72, CatromFilter,1.0);
the resolution doesnt change. The only thing that changes is the pixel size. But if I resample to 180x180

Code: Select all

MagickResampleImage(magick_wand, 180, 180, CatromFilter,1.0);
the pixel size doesnt change, only the filesize gets a bit smaller. The size of my pic gets from 400KB->180->30 (resample(180x180) and then resize(640x480)) and 400->30->30 ( resize(640x480) and after that resample(180x180)). So I decided to just resize. [/i]

All I know is that I have different pictures with different resolutions and/or different pixel size. I want that they are after this conversion 640x480. So should I use resample or resize?

2. If I set the compression level nothing changes.
EDIT: I tested it out and when I set the compression quality down both resampling and resizing change.

What is the difference between MagickSetImageCompressionQuality and MagickSetImageCompression?
My pix shouldnt be bigger than 50KB (some became 70KB some 190KB). How can I ensure that my image gets smaller than 50KB. I mean I would start with the best quality and then write this file, check the filesize and then so this as long as it is bigger. Is that a reasonable way?

3.Which filter?
I found a nice pagehttp://www.dylanbeattie.net/magick/filters/result.html that shows the different filters. I couldnt find which is the bes for my purpose, though. I tried several different and couldnt see any difference. I m sitting on a laptop and so just a little movement with my head makes a difference. I think that Catrom, Lanczos and Sinc are the best. What are your experiences?

Re: resize vs resample, which compression and which filter :S

Posted: 2007-10-01T21:48:12-07:00
by anthony
Resize is a proper orthogonal image resizing operation. You can select the filter and adjust the bluring of the filter using the mis-named 'suport' factor.

Resample is another 'misnamed' function it is really a resize that uses changes in resolution or 'density' to determine the new size of an image in pixel terms.

Do not confuse these with true 'area resampling' which is used in image distortion, including resize, but in a much more general sense. I myself only just added internal magickCore function 'EWA Resampling' to IM that is used by the new Generalized Distortion Operator to produce better images at high minifications. This is a true resampling function, designed specifically for distorted images, and is the sort of thing image processing truely terms resampling.

See IM Examples, 'Viewing Distant Horizons' for examples of this...
http://www.imagemagick.org/Usage/distorts/#horizon