Auto detection of image orientation

Discussion in 'Digital Darkroom' started by will_perlis, Sep 19, 2002.

  1. Does anyone know of an easy way to detect in software the
    orientation of individual images (portrait vs landscape) for auto-
    sorting into different directories?

    If I have to, I can program a routine from scratch, but I was hoping
    to save the time and effort.
     
  2. Don't know of anything that would do what you're looking for. You may know this but check out this link.

    http://www.faqs.org/faqs/jpeg-faq/part1/section-22.html
     
  3. btw... is there something at a higher level you are trying to accomplish? There might be another way to do it.
     
  4. Tom,

    I'm looking for a way to batch process jpgs for the net so the portrait images come out to be 400x600 pixels and the landscapes come out to be 600x400 pixels. As it is, when I mix the two flavors and do a batch re-sizing in Photohop with the width set at 400, the portraits come out at 400x600 but I get landscapes that are 400x267.

    A method of sorting the two orientations out first would solve the problem elegantly enough for my purposes.
     
  5. I think the panacean Imagemagick can do this. It comes with a utility called "identify", which you can use to extract the dimensions of the image. After writing a batch/shell file to separate the portraits from the landscapes, you could then invoke "convert -rotate" or "jpegtran" (lossless) to rotate the image. You could even do it all in compiled code using ImageMagick's programming interface.
     
  6. I think the easiest way to do this would be to just write a small program that opens each file, and moves it to folder A or folder B, depending if (width > height) or the other way around. Unfortunately, I don't know if such a program already exists; if not, it should be rather straightforward to do. Which platform (OS) and other software do you use?
     
  7. Batch mode in Photoshop 7 allows you to take from the file browser - so you can size when all are horizontal, for example, then batch the ones that need turning. Hey presto, everyones a winner baby.

    (Why in Gods name did I type that?)
     
  8. William,

    I had a feeling this is what you were trying to do. I had to do something similar recently. The best thing to do is use ImageMagick (http://www.imagemagick.org) The command line should include -size 600x600 and it will resize the image so that it's largest dimension in either direction is 600pixels. You can even sharpen the image the image, since you are resizing, as well as throw in borders and copyright all in one shot.

    It's a very popular set of tools and will do just what you need.
     
  9. Ummm... I hate to admit being this dumb, but I just twigged to the easy answer about five minutes ago. The thing to do is re-size the jpgs as 600 wide by 400 high first, and *then* rotate the portraits into their proper orientation. That way they all come out 600 by 400 for the landscapes and 400 by 600 for the portraits.

    What was confusing me is I had rotated them first, when they came off the D30.

    ImageMagick looks like the way to go in the future, that way I can flip them as needed for examination, and then edit and discard before processing any further.

    Thanks, all.
     
  10. William,

    Let me give you a rundown of my digital workflow. I don't shoot digital but scan my work. Color at high res and black and whites at medium since I print them in the darkroom.

    I scan all the images and go through them in photoshop making adjustments to color, contrast, etc. I also change the orientation if needed. I then run a script that then works off of those images to create 4 new sets of images. One set for CD with thumbnails and another slightly lower res set with thumbs for my online proofing system. Copyright statement included. One command and I can walk away. With Photoshop batch processing we're talking about 5 or 6 that I'd manually have to initiate. I think there might be a more powerful scripting engine for PS actions but I don't have it and imagemagick works perfectly and I can start it from batch files or java programs. For times that I have 10 or so rolls to go through it really appreciate the time I took to work on the scripts.
     
  11. "...powerful scripting engine for PS actions..."

    Tom,

    Thanks again. Adobe has a scripting engine for PS7 but I haven't looked closely at it yet. A glance showed what looked like "MS Visual" code along the lines of:

    "MyUniverse.MyGalaxy.MySolarSystem.MyPlanet.MyEtcetra.MyNausea...."

    I can handle it, I just need a few drinks first.
     
  12. Use the Automate -> Fit command. Set the width for 600 and the height for 400. This constrains the image to "fit" within a 600x400 frame.
     

Share This Page