| Davyd ( @ 2008-04-22 00:00:00 |
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).
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).