Page 1 of 1

fixed pixel aspect ratio and fixed resolution

Posted: 2011-02-06T08:25:58-07:00
by john_q61
I am using Magick++. My program continuously reads dynamically varying JPEG images from the disk. These images are written to the disk continuously by another program. The images are of the same object (say a square or a cube or a teapot). But they are dynamically varying in pixel aspect ratio and resolution. I want to display these images with fixed pixel aspect ratio and fixed resolution. Here is what I do -

Pseudo code -
total_rows = image height;
total_cols = image width;
if(image height > image width) {
total_cols = image width + (image height / image width)
}
else if(image width > image height) {
total_rows = image height + (image width / image height)
}

image.extnt(total_rows X total_cols, CenterGravity)

This gives me images of fixed pixel aspect ratio across all images. But the images are dynamically varying in resolution.

How can I get a fixed resolution as well? I tried to use image.resize (tried with both with and without ! option) after using image.extent but it changes the pixel aspect ratio.

Appreciate any help/pointers. Thanks in advance.

Re: fixed pixel aspect ratio and fixed resolution

Posted: 2011-02-07T18:20:12-07:00
by anthony
-resample will fix resolution to the settings given. This is basically a resize with calculations based on changes in resolution.

http://www.imagemagick.org/Usage/resize/#resample