6
$\begingroup$

I have a bunch of mixed images, some portrait orientation, some landscape, which I want to be processed by Mathematica. When I Import them Mathematica handles them all as landscape image, also when resaving, even though e.g. Photoshop and Directory Opus are aware of the orientation. (Windows Explorer isn't.)
Is there a way Mathematica can tell when an image was created in landscape or portrait?

I'm using version 9.0.1.0.

$\endgroup$
9
$\begingroup$

Orientation is not part of the image itself; it is stored as metadata. In version 10.1 at least it seems that this data is respected. One can also read this value using the Import element "CameraTopOrientation":

Import["file.jpg", {"JPEG", "CameraTopOrientation"}]
Right

A numeric value can be read from "Exif":

"Orientation" /. Import["file.jpg", {"JPEG", "Exif"}]
6

The meaning of these values is described here: http://sylvana.net/jpegcrop/exif_orientation.html

If Mathematica does not handle this automatically for some reason you should at least to able to read the value and rotate it as required. That is unless you set the orientation in an external utility that keeps the data in a "sidecar" file of some sort that only it reads.

$\endgroup$
  • $\begingroup$ Thanks, Wizard (again! :-)). Works in version 9 too, but I couldn't find any of this information in the help system. $\endgroup$ – stevenvh Jul 21 '15 at 16:00
  • $\begingroup$ @Steven You're welcome, as always. By the way I noticed that you stopped answering questions on Electronics.SE; I don't mean to pry but I am curious why? $\endgroup$ – Mr.Wizard Jul 21 '15 at 19:35
  • $\begingroup$ Yeah, I haven't been there in years. (Too) busy with other things. However, every now and again I get an electronics question via my site (it's on my profile), and I still try to help people out. $\endgroup$ – stevenvh Jul 22 '15 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.