Page 1 of 1

Imagemagick api

Posted: 2013-04-29T04:13:26-07:00
by javarc
Hi,

I've just started using Imagemagick - thank you, it looks great!

I'm using an android port from here:

https://github.com/puelocesar/android-lib-magick

and I have to use the API directly, so running into some issues. Could anyone help me define the api call to correctly resize an image preserving the aspect ratio? I think I'm close, but can't find an example anywhere after much searching. Here's what I got:

img = new MagickImage(new ImageInfo(filename));
scaledImage = img.zoomImage(dimensions.getHeight(), dimensions.getWidth());
scaledImage.unsharpMaskImage(0, .75, .75, .008);

It almost works, but the aspect ratio is not preserved. I know that its fairly easily done from the command line, but having some troubles seeing the way via the api...

Thank you!

Mark

Re: Imagemagick api

Posted: 2013-04-29T04:42:40-07:00
by magick
Get the image dimensions and compute the aspect ratio of the resized image with simple math. If the API supports TransformImage() you can set a resize geometry as a string and ImageMagick will set the resize dimensions while maintaining the aspect ratio for you.