ExifTool Forum

General => Metadata => Topic started by: linuxuser on July 24, 2013, 05:35:57 PM

Title: How to write "intelligent orientation"
Post by: linuxuser on July 24, 2013, 05:35:57 PM
Some cameras don't have an orientation tag, but even with it, it can't be wrong if you made a crop. Can exiftool write an orientation tag based on the dimensions?
Title: Re: How to write "intelligent orientation"
Post by: Phil Harvey on July 24, 2013, 06:28:58 PM
How would you differentiate a CW from a CCW rotation by 90 degrees using only the image dimensions?

- Phil
Title: Re: How to write "intelligent orientation"
Post by: linuxuser on July 25, 2013, 05:05:30 AM
I assume you mean that a portrait-photo can be viewed upside down. I make photos in raw-format and after they are processed, the photos are converted to jpg and then they are viewed as they should without any orientation tag. Don't know if it helps for my Samsung mobile phone to define an orientation tag to see photos in portrait mode in full size. Photos in landscape format use the full size, but photos in portrait mode are rotated to landscape mode. So I would like to add an orientation tag to my processed photos.
Title: Re: How to write "intelligent orientation"
Post by: Alan Clifford on July 25, 2013, 07:37:24 AM
You are putting the jpegs processed from raw onto your phone I guess?

This is what I think is happening.  You take a raw portrait photo.  It has an orientation tag that tells viewing software to rotate it to be viewed

Image Size                      : 4992x3280
Orientation                     : Rotate 90 CW

When you processes it, the software physically rotates the photo and changes or removes the orientation tag

Image Size                      : 3264x4928
Orientation                     : Horizontal (normal)

What you need to try is to physically rotate the photo back to landscape format and put in the orientation tag.  With easy to use, clicky software, it is difficult to determine whether a "rotation" is done with the orientation tag or by rotating the photo so I'd suggest using jpegtran for the rotation and exiftool to put in the orientation tag.

So, start with a photo and have a look at it

exiftool -imagesize -orientation rotationtest.jpg
Image Size                      : 3264x4928
Orientation                     : Horizontal (normal)


Then rotate it

jpegtran -rotate 270 -copy all rotationtest.jpg > rotationtest_rotated.jpg


and have a look

exiftool -imagesize -orientation rotationtest_rotated.jpg
Image Size                      : 4928x3264
Orientation                     : Horizontal (normal)


Then plug in the orientation tag

exiftool -orientation#=6 rotationtest_rotated.jpg


And have a look

exiftool -imagesize -orientation rotationtest_rotated.jpg
Image Size                      : 4928x3264
Orientation                     : Rotate 90 CW



Your phone will treat this as a portrait - optimistic huh?

PS  Don't do this on your original photos, use copies.  That's my disclaimer.
Title: Re: How to write "intelligent orientation"
Post by: Alan Clifford on July 25, 2013, 07:41:31 AM
Phil, I've probably asked this before.

The raw file I used in the previous post had with exiftool

Image Size                      : 4992x3280

but the Nikon viewer shows 4928x3264 which was the size of the processed jpeg.  I am guessing the Nikon software is using the size of the embedded jpeg.  Just checking that now.
Title: Re: How to write "intelligent orientation"
Post by: Phil Harvey on July 25, 2013, 07:45:16 AM
Alan,

Determining the size of a RAW image is not an exact science.  ExifTool just gives the size of the RAW image data, but sometimes there is a masked border in the data that is removed when the image is developed.  Also, not all development software removes the same amount (dcraw for example, may give you images that are a few pixels larger than most other software).

- Phil
Title: Re: How to write "intelligent orientation"
Post by: linuxuser on July 25, 2013, 09:53:49 AM
What I do is:

I make a PEF-file with the camera.

Then I use AftershotPro (Linux) and develop the photo. This means I rotate it with Aftershot if needed. So there can be a situation, where a photo was shot in landscape format and I crop it to portrait format. Then the photo is converted to jpg with max. resolution. From this jpg-file I create a jpg-file with the native resolution of the display of the mobile phone. I remove _all_ metadata in the jpg-file of the mobile phone and then I add a few.

exiftool -q -q -overwrite_original -tagsfromfile "$ORIGINALQUALITYFILE" -EXIF:CreateDate -EXIF:ModifyDate -EXIF:DateTimeOriginal -GPS:GPSLatitude -GPS:GPSLatitudeRef -GPS:GPSLongitude -GPS:GPSLongitudeRef -GPS:GPSAltitude -GPS:GPSAltitudeRef -GPSMeasureMode -GPSMapDatum "$ANDROID320_FILE"

So the file doesn't contain any orientation tag. The result works fine with my android-phones, but not with the Samsung GT-C3520. Simply I think the firmware of Samsung is crap, when it comes to details (as so often). If I add an orientation tag with portrait format images, the image is rotated at the pc and therefore displayed wrong. To add a horizontal orientation always is useless IMHO. So I think I have to accept it, that portrait photos are rotated with the GT-C3520 and are displayed in a smaller size.