Imagemagick api

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
javarc
Posts: 1
Joined: 2013-04-29T04:09:55-07:00
Authentication code: 6789

Imagemagick api

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Imagemagick api

Post 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.
Post Reply