Page 1 of 1

Image::zoom function in Magick++

Posted: 2007-09-19T04:48:52-07:00
by eldiener
The documentation in Magick++ for the Image::zoom function is pretty sparse:

"zoom const Geometry &geometry_ Zoom image to specified size."

That's it !

Does anybody know what this is supposed to do, as opposed to, let's say, Image::scale among many others Image resizing functions in Magick++ which also take a Geometry ?

Am I supposed to be using the Geometry which takes the % qualifier ? If so, am I supposed to be use the exact same width and height amounts with the % qualifier ?

I would have thought, being the naive person I am, that an image zoom function would just take a single parameter, which would be the amount to zoom as a percentage of the current size, with amounts greater than 100 making the image proportionally larger and amount less than 100 making the image proportioanlly smaller.

I really appreciate that ImageMagick and Magick++ are free, but the online programming docs make it a real chore to figure out what to do unless one is of the "try it out and you might figure it out" school of programming.

Re: Image::zoom function in Magick++

Posted: 2007-09-19T06:21:16-07:00
by magick
Zoom accepts a Geometry or string. The string is typically a percentage, for example
  • image.zoom("50%")
reduces an image to 1/2 its size. The algorithm uses a finite impulse response filter to perform the resize. By default Magick++ uses the Lanczos filter when the image size is reduced otherwise the Mitchell filter.

Re: Image::zoom function in Magick++

Posted: 2007-09-20T04:35:58-07:00
by eldiener
magick wrote:Zoom accepts a Geometry or string. The string is typically a percentage, for example
  • image.zoom("50%")
reduces an image to 1/2 its size. The algorithm uses a finite impulse response filter to perform the resize. By default Magick++ uses the Lanczos filter when the image size is reduced otherwise the Mitchell filter.
That is wonderful, and how I thought it should work.

The documentation for a Geometry string says that it takes the form of:

"<width>x<height>{+-}<xoffset>{+-}<yoffset>{%}{!}{<}{>}"

This suggests to me that both width and height are mandatory, while everything else is optional. But your example of using "50%" shows a single percentage value. Does this mean that both width and height are not mandatory ? Is this the only case where one can specify a single value ? If there are other cases where one can specify a single value, what does specifying a single value mean ?

I am guessing that the generalized rule for specifying a single value is that it refers to both the width and height, so that "50%" is shorthand for "50%x50%" etc. Is this correct ?

If specifying a single value is allowed as you have implied, it would be nice if the online Magick++ documentation for Geometry were updated to reflect this.

Thanks !

Re: Image::zoom function in Magick++

Posted: 2007-09-24T19:15:01-07:00
by anthony
Generally if only one value in a geometry sting is given then the other value is
set to infinity. For resizes geometry is a 'best fit preserving aspect ratio' unless a '!' is given. With percentages. If any percent symbol is given anywhere both width and height are percentage values of the original image.

Basically 50% will result (due to aspect ratio preservation) in 50%x50%