Davyd ([info]davyd) wrote,
@ 2008-04-22 00:00:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
jpegexiforient broken?
For quite a while, when uploading to Original, I've run the photos through exifautotran, a shell script that uses jpegexiforient to read the EXIF Orientation flag and rotate each image for the web. Since getting the 450D I'd noticed that exifautotran was no longer doing anything, which I tracked down to jpegexiforient returning no orientation (nor being able to set the orientation either). I thought this was weird because GNOME (eog, f-spot, nautilus, gthumb) and MacOSX (Finder, Preview) both displayed the photo correctly.

Today I had a look at the source code to jpegexiforient and I found that it was silently returning because the first byte of the file was not FF, D8, FF, E1. Using my trusty hex editor I discovered that my file starts FF, D8, FF, E0. FF, D8 indicates the beginning of a JPEG file and from the EXIF spec, it can be seen that FF, E0 is the beginning of a JFIF block. In my file FF, E1, the beginning of the EXIF block, doesn't appear until after this. So while there is nothing wrong with my file as far as I can tell, jpegexiforient won't accept it.

My solution? I'm now using the program jhead to batch-rotate images, which seems to work correctly and also provides a number of other useful features.

It's worth noting that Windows Media Centre also didn't like the orientation flag. Neither did whatever version of Elisa I'm currently running (which is not the latest).


(Post a new comment)

It happens a lot...
(Anonymous)
2008-04-21 07:20 pm UTC (link)
From http://en.wikipedia.org/wiki/JFIF:

Formally, the Exif and JFIF standards are incompatible. This is because both specify that their particular application segment (APP0 for JFIF, APP1 for Exif) must be the first in the image file. In practice, many programs and digital cameras produce files with both application segments included. This will not affect the image decoding for most decoders, but poorly designed JFIF or Exif parsers may not recognise the file properly.

(Reply to this)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…