Sunday, September 21, 2008

Getting a photo aspect ratios correct using IrfanView

Getting the aspect ratio of a portrait photo right can be tricky if you want to put it in a Web page. Especially if the place you are going to put the photo is expecting a certain width x height ratio. That is the aspect ratio and if you get it wrong the photo will look squashed or elongated.

My company's Directory Update and Directory Manager software allow you to upload a JPG photo in to the Active Directory. The photo is then stored in the user's jpegPhoto attribute as an octet stream. By default, our DirectorySettings.XML file uses a default photo size of 130 pixels wide by 170 pixels high for the photo (that is an aspect ratio of 3:4). Whatever you upload will be re-sized in to that particular ratio so the original file should have the same aspect ratio.

Here is a good way to make sure that your "source photo" is the right aspect ratio. I have found some good, powerful, and free software that will help you do this. It is called IrfanView. (If you download this software and find it useful, send the author some money via his web site, even just 10 euros or something.) Install the IrfanView software and follow these steps to resize a photo:

  1. Load the original photo in to IrfanView (in my example the original photo was 2.2MB and is 2592 x 1944). You will probably need to "zoom out" a bit so that you have the whole photo on your screen.
  2. Next you need to "crop" the photo to keep only what you want. Using the mouse, select the part of the picture that you want to keep; try to select the photo in roughly the size that you want. You will notice an outline around the selected area.
  3. From the Edit menu, select Create Custom Crop Selection (or just SHIFT+C).
  4. On the Create Custom Selection box, select the 3:4 ratio and then click the Apply To Image button. Notice now that your selected area on the photo is now slightly changed. If this is the desired "portrait", then you can proceed, otherwise go back to Step 2.
  5. On the Edit menu, choose Crop Selection. Ta da! You have a new image!
  6. Save the new image as a JPG file. My new image is now 91KB and is 629 x 839. Yes, that is a weird size, but it is the RIGHT aspect ratio.
  7. Now I can upload the image in to Directory Update or Directory Manager without it being stretched or squashed. Once uploaded, the Directory Update or Directory Manager software will "resize" the image to be 130 x 170. The resulting image file size is approximately 5KB.
You can, of course, modify this procedure to use a different aspect ratio than the defaults, but this is just what works out-of-the-box with Directory Update and Directory Manager.
Thanks to's "TechTips" for re-introducing me to IrfanView.



Post a Comment

<< Home