Jump to content

Auto detection of image orientation


Recommended Posts

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.

Link to comment
Share on other sites

I think the panacean Imagemagick can do this. It comes with a utility called "<a href="http://www.imagemagick.org/www/identify.html">identify</a>", 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 "<a href="http://www.imagemagick.org/www/ImageMagick.html#details-rotate">convert -rotate</a>" or "<a href="http://www.nmt.edu/tcc/swinv/jpeg/6b/man/jpegtran.1.html">jpegtran</a>" (lossless) to rotate the image. You could even do it all in compiled code using <a href="http://www.imagemagick.org/">ImageMagick's</a> programming interface.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

"...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.

Link to comment
Share on other sites

  • 7 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...