specifying algorithms for Image::scale()/sample()

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

specifying algorithms for Image::scale()/sample()

Post by whatdoido » 2012-03-31T09:27:21-07:00

Hello

is it possible with the Magick++ i/f to specify the scale/resize algorithm? The API only provides ::scale() and ::sample()

User avatar
fmw42
Posts: 25555
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: specifying algorithms for Image::scale()/sample()

Post by fmw42 » 2012-03-31T09:45:55-07:00

I am not an API user, but there should be the equivalent resize() with filter option to the command line -filter xx -resize.

see
http://www.imagemagick.org/Usage/resize/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: specifying algorithms for Image::scale()/sample()

Post by anthony » 2012-04-01T23:23:14-07:00

scale and sample are simply faster varients of specific filters in the resize() operation.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

whatdoido
Posts: 27
Joined: 2011-01-22T16:54:46-07:00
Authentication code: 8675308

Re: specifying algorithms for Image::scale()/sample()

Post by whatdoido » 2012-04-04T06:01:23-07:00

Thanks.

After the mention of "filters" I revisited the Image documentation and found

Code: Select all

Image::filterType(...)
[/b] and states:
"Filter to use when resizing image. The reduction filter employed has a sigificant effect on the time required to resize an image and the resulting quality. The default filter is Lanczos which has been shown to produce high quality results when reducing most images."
I am scaling down/resizing photos (portraits) from >4k on longest edge to 1024 or smaller. Using the scale/sample methods the output image makes the people in the images look to have "jaggered" edges.

Will use Image::resize() as suggested and specifying the filter as appropriate as my current usage of scale/sample seems to use no advance filter at all - the documentation:

sample() - Resize image by using pixel sampling algorithm
scale() - Resize image by using simple ratio algorithm


Thanks all.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: specifying algorithms for Image::scale()/sample()

Post by anthony » 2012-04-05T01:32:42-07:00

As I mentioned sample() and scale() are fast non filtered versions of resize()

The documentation does not seem to mention resize() but I am sure it must be their somewhere!
Perhaps under the old (IMv4) terminology of transform()????

This was a function that either resizes or cropped the image based on a string. It is old.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply