fixed pixel aspect ratio and fixed resolution

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
john_q61
Posts: 1
Joined: 2011-02-06T06:30:31-07:00
Authentication code: 8675308

fixed pixel aspect ratio and fixed resolution

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: fixed pixel aspect ratio and fixed resolution

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply