potential bug? or my mistake

Added by lestat lestrange 3 months ago

exiftool -b -ThumbnailImage test.cr2 > thumbnail.jpg

Returns a rotated thumbnail. Why?


Replies (5)

RE: potential bug? or my mistake - Added by Robin Mills 3 months ago

Can you attach a test file and I will look at it? There is no pixel processing code in Exiv2, so images/thumbnails are never rotated, scaled, cropped or resampled. The image and previews are exactly what was stored by the camera manufacturer.

There is a metadata item Exif.Image.Orientation which can have a value 0..7 The values determine orientation. I've forgotten the spec and in effect 3 bits which represent how the image is encoded. left-to-right (or right-to-left), top-to-bottom (or bottom-to-top) not-rotated (or rotated). This can be set when the camera is rotated. http://www.exiv2.org/tags.html

There could be additional information in the MakerNotes (the Camera Manufacturer's private data). Exiv2 can usually read/modify/rewrite MakerNotes. If Exif.Image.Orientation isn't specified (or is zero), please look at all the metadata and you'll probably find an explanation. http://www.exiv2.org/tags-canon.html

There's a discussion about this on Canon's Forum: http://community.usa.canon.com/t5/EOS-Rebel/Thumbnail-and-Image-not-in-the-same-orientation-in-Windows/td-p/211563

RE: potential bug? or my mistake - Added by lestat lestrange 3 months ago

I cannot attach the image, it is 25b. Here is a drop box of it.

https://drive.google.com/file/d/0ByFF9-5uQ-qIcTRtbWEyMHk4S0E/view

Every file under that folder returns a sideways thumbnail.

RE: potential bug? or my mistake - Added by Robin Mills 3 months ago

Thank you for your files.

I found the following discussion about Orientation: http://sylvana.net/jpegcrop/exif_orientation.html

When I use the exiv2 image debugging feature -pR (print Structure Recursively), I see:

868 rmills@rmillsmbp:~/Downloads/Origs $ exiv2 -pR TR01_Oatmeal_David_17-07-24_001.CR2  | grep -e ImageWidth -e ImageLength -e Orient
      18 | 0x0100 ImageWidth                |     SHORT |        1 |      5760 | 5760
      30 | 0x0101 ImageLength               |     SHORT |        1 |      3840 | 3840
     102 | 0x0112 Orientation               |     SHORT |        1 |         8 | 8
   71854 | 0x0100 ImageWidth                |     SHORT |        1 |       592 | 592
   71866 | 0x0101 ImageLength               |     SHORT |        1 |       395 | 395
869 rmills@rmillsmbp:~/Downloads/Origs $
As you can see the Orientation is 8 which is a rotated image. Canon stored a landscape 5760x3840 pixel image with orientation 8 (one of the rotated directions described in the reference above). They also stored a preview landscape 592x395 pixels image which, I assume, is a downsampled version of the larger image. As Exiv2 does not have code to manipulate the image, the preview has been extracted accurately in landscape.

Image viewers (such as Preview on the Mac), understand the Orientation tag and rotate the image when it is displayed. However, the image (and the preview) are stored in landscape.

RE: potential bug? or my mistake - Added by lestat lestrange 3 months ago

Can you show me the terminal command to flip the image to a regular picture for these pictures?

RE: potential bug? or my mistake - Added by Robin Mills 3 months ago

It's not the business of Exiv2 to manipulate the pixels in an image. On the Mac, you can rotate the image with the sips command:

$ sips --rotate 90 foo.jpg
On other platforms, Image Magic provides tools for many image processing operations. For example:
$ jpegtran -rotate 90 foo.jpg > foo90.jpg 

Here is a reference to a discussion about image rotation. Previews never contain metadata because this is forbidden by the Exif specification. The author or this article discusses using ExifTool to insert the Orientation tag into the image. Exiv2 can do the same task. For most image viewers, this would appear to rotate the image. In effect, the orientation tag is like putting the television on its side. The image has not been modified, you have rotated the viewer. http://www.imagemagick.org/discourse-server/viewtopic.php?t=21341

(1-5/5)

Redmine Appliance - Powered by TurnKey Linux