How to resize/resample image using MagickCore

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
wchang615

How to resize/resample image using MagickCore

Post by wchang615 »

Hi,

I want to use the MagickCore to do the exact the same as the command-line "Convert -resize 64x64 input.jpg output.jpg" which wil scale the image accordingly rather than fix the dimensions as in ResizeImage, SacleImage, etc. for given the column and row size.

When using command-line "Convert" for a given image with geometry of 2492x1944+0+0, after resize with 64x64, it produced geometry with 64x48.

How would I do that?

Thanks for any help.

Best,

--Wo
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How to resize/resample image using MagickCore

Post by magick »

Use TransformImage() if you want the aspect ratio of the image to be respected. ResizeImage(), as you have seen, resizes to the exact image dimensions you provide.
wchang615

Re: How to resize/resample image using MagickCore

Post by wchang615 »

Great and thanks, it works!
BTW: I also see the TransformImages, how does this work?
By looking at the parameters:
MagickBooleanType TransformImages(Image **image,
const char *crop_geometry,const char *image_geometry)

how do you provide a list of images? Are there any advantages of using TransformImages vs. TransformImage? If it does cut down the processing time, I'd be very interested since I have over 5,000+ pictures to process.

Thanks again for any answer.

--Wo
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: How to resize/resample image using MagickCore

Post by magick »

Use TransformImages() if you want to resize a list of images. A GIF image may have 10 frames, for example, and TransformImages() will resize (or crop) all 10 frames in the sequence.
wchang615

Re: How to resize/resample image using MagickCore

Post by wchang615 »

Good feature! Thanks for the info.

--Wo
Post Reply