Return to Digital Photography Articles

JPEG Rotation and EXIF Orientation

Digital Cameras with orientation sensors allow auto-rotation of portrait images. Unfortunately, support for this feature is not widespread or consistently applied.

Digital Cameras with Orientation Sensors

Many newer digital cameras (both dSLR and Point & Shoot digicams) have a built-in orientation sensor. Virtually all Canon and Nikon digital cameras have an orientation sensor. The output of this sensor is used to set the EXIF orientation flag in the image file's metatdata to reflect the positioning of the camera with respect to the ground. Canon calls their sensor the "Intelligent Orientation" sensor. It is presumably a 2-axis tilt sensor, allowing 4 possible orientations to be detected (shown in the left side of the diagram below).

EXIF Orientation Flag Values
Note: Previous orientation image can be seen here

 

Note that one would only expect the four orientation settings shown on the left to be possible with a digital camera. The other four settings would imply that the resulting image was flipped horizontally before recording. Unless the camera were to encode the image right-to-left or know that you were taking a photo in a mirror, I don't see how these values will ever be used.

For the following discussion, it may be helpful to understand the concepts behind lossless rotation.

The values 1-8 represent the following descriptions (as shown by utilities that support EXIF field decode):

EXIF Orientation Value Row #0 is: Column #0 is:
1TopLeft side
2* TopRight side
3BottomRight side
4* BottomLeft side
5* Left sideTop
6Right sideTop
7* Right sideBottom
8 Left sideBottom

NOTE: Values with "*" are uncommon since they represent "flipped" orientations.

Auto-rotation in Digital Cameras

While your digital camera may include an option to "auto-rotate images" due to the camera's orientation, this is almost always just a "virtual rotation". A flag is set to indicate to the viewing software / LCD preview which way to rotate the image before display, rather than rotating the image content itself.

As lossless image rotation is a fairly compute-intensive operation, digital cameras are not likely to include true lossless rotation after capturing the photo. The CCD/CMOS sensor hardware is designed to stream raw data in a particular direction (e.g. rows then columns), and so it may be hard to incorporate true auto-rotation in-camera without a performance impact to continuous shooting (frames per second).

Software Support for Orientation

While there are countless software programs available today that display JPEG images, only a subset of them actually interpret the EXIF Orientation flag. Just like color management, many programs simply display the JPEG image as it is stored, and completely ignore any extra details stored in the file's metadata. The most important of these additional details is the Orientation flag, stored in the JPEG APP1 marker under EXIF IFD0.

Application Orientation Supported?
Windows Photo Viewer (Windows 7) No
Windows Picture and Fax Viewer (Windows XP)No
IrfanView Yes (need to enable)
Photoshop Yes

IrfanView Auto-rotation

In IrfanView, auto-rotation is not enabled by default. To ensure that images are auto-rotated, you will find the option located under Options->Properties in the JPG/PCD/GIF tab.

Windows Picture and Fax Viewer

Surprisingly, the Windows Picture and Fax Viewer (built into Windows XP) and Windows Photo Viewer (built into Windows 7) do not support the EXIF orientation flag. This is surprising, as the makers have obviously thought enough to support lossless rotation functions. So, what you will see shown by the viewer is the real image data (assuming landscape orientation), without respecting any indication from the camera as to the real orientation of the image.

Beware of Rotating Photos in Windows Picture / Photo Viewer!

Another surprising detail is that if you decide to perform lossless image rotation (by using the Rotate Clockwise or Rotate CounterClockwise buttons), the EXIF Orientation flag is removed! As the flag is removed/reset, if you do a rotation followed by its reverse rotation on a portrait photo (eg. rotate clockwise, then rotate counter-clockwise), the resulting orientation observed by other viewers such as Photoshop will be wrong!

In fact, when you use the rotate functions of Windows Picutre Viewer, most of the image metadata (camera information, shot details, makernotes, etc.) are deleted. Therefore, I strongly recommend against using this program to rotate any of your digital photos.

I have also noticed that some images which were rotated that don't conform to 16x16 pixel multiples, the quantization tables don't appear to be rotated properly.

Because many new digital photographers may not be aware of this, Nikon even went so far as to issue a press release to warn of the potential dangers.

  • NOTE: The damage is done as soon as you press one of the rotate buttons . The disk icon is just for copying the file and should not be thought of as a Save button!

The following table details some of the metadata corrupted / modified by Windows Picture and Fax Viewer:

RemovedAddedModified
IFD0-Orientation IFD0-x1001
IFD0-x1002
IFD0-xA401
IFD0-xA402
IFD0-xA403
 
SubIFD-ExifInteroperabilityOffset
SubIFD-CustomRendered
SubIFD-ExposureMode
SubIFD-WhiteBalance
SubIFD-SceneCaptureType
  SubIFD-MakerNote
SubIFD-UserComment
MakerNotes: Nearly all fields zeroed
out except: SerialNumber, ImageNumber
   

 

Note that, in general, most image editors (such as Photoshop, Lightroom and many others) do not rotate images losslessly. This is made obvious by the fact that the Save function provides compression quality options (eg. 1-12, High, Low, etc.) and is therefore applying [lossy] JPEG recompression to your image content.

Auto-Rotation Utilities

There are several tools that allow the image content to be rotated losslessly in software, based on the information stored in the EXIF orientation flag. By far the best time to perform this is during image import (e.g. from memory card). Most import applications (such as DownloaderPro) can do this during the copy operation (from memory card to hard drive). Doing so ensure that all programs can see the image properly rotated, without having to rely on the EXIF Orientation flag. This means that even programs such as Microsoft's Windows Picture and Fax Viewer will also show correct orientation for portrait / vertical images.

Most programs will rotate the image content and then update the Orientation flag to reflect the new orientation (usually a value of 1), while still leaving other metadata intact.

 


Reader's Comments:

Please leave your comments or suggestions below!
2018-04-24VirgB
 I found that Picasa detects when the orientation flag is used if you view "Properties". Then all you have to do is save the file to convert the JPEG that uses it into a universally acceptable format. Unfortunately, Picasa is no longer supported and its replacement, Google Photos, does not have this feature.
2017-02-26Clare
 Actually, saving the photo to Windows Paint corrected the orientation problem for me.
2016-11-17Mike Wilson
 It looks like the Windows Photo Viewer and the thumbnail view in File Explorer for Windows 8 and Windows 10 now honor the Orientation flag in EXIF. However, this has caused a lot of confusion for users who upload the photos to websites like Facebook, eBay, or Amazon. The pictures look "Normal" in Windows 10, but when they are uploaded to other websites, they are rotated sideways.

Most users try to fix the problem by using the "Rotate Left" and "Rotate Right" features provided by File Explorer in Windows 10. That doesn't solve the problem because it only updates the Orientation flag in EXIF. So when the pictures are uploaded to other websites (which don't usually honor the Orientation flag), they are still rotated sideways.

Here's an article that explains the issue and how to solve it using the good old Paint program that comes with Windows: http://www.ivertech.com/Articles/Image-Rotation-Issue-With-Windows-10.aspx
2014-12-08AlexisPERR
 Hi all, the command line tool to reset the EXIF orientation to 1, while losslessly orienting the picture AND the EXIF thumbnail is JHEAD

JHEAD -v -autorot C:pictures***.jpg

for recursive action
 Thanks Alexis for the command-line method!
2014-12-02Ahmad Ibrahim
 Very useful link .
2014-05-02Doug Chartrand
 I recently published an android application to help with this problem by performing lossless jpg rotation according to the exif orientation flag and resetting the flag so that the viewer does not perform any additional rotations: https://play.google.com/store/apps/details?id=net.chartrand.doug.photorotator
2014-03-17Peter Saitz
 Windows 8 and 8.1 displays photos correct in Windows Explorer (view option "big icons" and "small icons"). Also when opened with Windows Photo Viewer (open with right-click and "Preview").
 Good to hear it's apparently fixed!
2013-06-29Milan
 Really really one of the most usefull article. Thanks a lot for sharing !
2013-06-20maplecao
 Thank you very much. What a awsome article.
2012-08-16David
 Awesome explanation, answered a lot of questions, thank you!
2012-08-16John Foster
 Wow! this detective work ( copied below) is the first clue I have see about video orientation.

Since camera phones and helmet cams are such a huge portion of video passed among folks on the web, it would be an act of kindness to begin documentation of video rotation to add to your contribution of still image rotation you have been demistifying in this land mark article on EXIF

Although you have found a valuable clue about the rotation of video for the iOS devices, I suspect that vendors such as the Contour Helmet cam, use a Windows based rotation scheme because of their FAT32 file size limit.

I wonder what rotation scheme is used by the various other helmet cams such as GoPro? I also wonder about various video sun glass cameras out of China?

"I just spent some time examining the iPhone MOV file format and it looks like you can detect the iPhone orientation for videos by extracting the Transformation matrix in the 'tkhd' atom (moov.trak.tkhd). Apple has documented the matrix here. Here is a link to some code for the patch to FFmpeg that detects the iPhone video orientation. As for QTKit, unfortunately I am not familiar with it."
 Thanks John! Unfortunately I don't have access to these other video cameras so I can't carry out the analysis to determine how they mark rotation. Note that in the case of the GoPro, it has an orientation flip setting that rotates the footage upon encoding. This saves the need for an orientation sensor and [potentially] non-standard orientation flag in the video file, however, I believe this is only vertical flip.
2012-08-15Paul
 Thanks for the expansion on Windows 7 ; moral seems even though improved stay well away from any rotations in Windows 7 Explorer or Photo Viewer. Amazing for such a simple fundamental issue that will confuse lots of non ethusiasts who will use Windows for this simple rotation process that Microsoft have got it so wrong for so long. Not tested my Apple Mac but hope that Apple don't have same problem.
 It does seem very surprising to me that even Windows 7 uses this implementation (I would call it a bug :)
2012-08-14John Foster
 http://en.m.wikipedia.org/wiki/Exchangeable_image_file_format#section_5
The problem section of this wiki explains that EXIF does not support video.

If you have any contacts who have a clue as to what sort of metadata Apple uses for making their orientation known to developers using QTKit, it would be an act of kindness to expand this article to include orientation of video files.
 I just spent some time examining the iPhone MOV file format and it looks like you can detect the iPhone orientation for videos by extracting the Transformation matrix in the 'tkhd' atom (moov.trak.tkhd). Apple has documented the matrix here. Here is a link to some code for the patch to FFmpeg that detects the iPhone video orientation. As for QTKit, unfortunately I am not familiar with it.
2012-07-31zarac
 Thank you. =D
2012-07-18Paul
 Very helpful article. It may be helpful to have short explanation as to what is meant by lossless rotation for those of us starting at lower knowledge. It would help to say if this has changed in windows 7 and also refer to windows explorer ( as Nikon press release ) and not just picture viewer. If something just changes the EXIF orientation flag is that not lossless as the raw fat is not changed only metadata and is that how program's such as Lightroom work?

Not sure I fully understand the “double rotation" comment. From what you seem to suggest you seem to be suggeting rotating with another lossless program, this would then set flafg to 1 and then in LIghtroom it would show correctly even though portrait but flagmismset to 1. Is it not easier just to use orientation flag?
 Hi Paul -- sure, I can update the article to start with a link to my description of lossless rotation as it is the basis for much of the description regarding rotation flags.

I just ran a test with Windows 7 (Windows Photo Viewer) and there is some good news and some bad news:
  • Rotation is lossless
  • The tags I checked are not lost like I observed in Windows XP
  • The EXIF orientation flag is still ignored by Windows Photo Viewer in Windows 7!
  • If you rotate an image in Windows Photo Viewer, you will essentially corrupt the Orientation flag
What happens is that the first rotation with the Windows Photo Viewer will reset the Orientation flag (if it exists) to top/left AND rotate the image content. If your original image was taken in a portrait orientation and the camera supported the EXIF orientation flag, then Windows Photo Viewer will essentially cause a double rotation.

For example, let's start with a portrait photo from a Canon T3i which supports the Orientation flag. The flag will be set to left/bottom (as opposed to top/left), which allows programs such as Photoshop and IrfanView to rotate the content upon display. When we rotate the image with the Windows Photo Viewer, it forces the Orientation flag to top/left AND rotates the image content. This is a double-rotation. If you were to open up this rotated file in Photoshop, you'll see that the orientation is now incorrect.

If you now rotate the image in the reverse direction, the image content will be rotated and the flags will still stay at top/left. Opening up the resulting image in Photoshop SHOULD show the original orientation, but instead you'll see it has been rotated!
2012-04-25Mehmet
 Thanks for your response Michael, I appreciate.
Unfortunately, such adroid applications are not gonna work for me until I buy another android mobile phone which is capable of taking sufficient quality pictures. I have one, however mine is not good enough for picturing every details (like of laminated siltstones).
Therefore, I still wish to hear another kind of advice like yours, including a digital camera advice having such a compass-like sensor within it.
Thanks
2012-04-16Michael Lee
 Mehmet, maybe this is a week late, and you may never see it, but I think the closest you can come to addressing your needs would be to use GeoCam from Sitis Mobile if you take photos with an Android-based or iPhone-based camera. It is free and works neat, so much so that I've made a (free) utility to work with it which stamps all the info GeoCam records when it takes a photo. Check out: www.gpstamper.wordpress.com/lite
Mike
2012-04-07Mehmet
 Hi,
Does anyone know how to put geographic directions, such as "N" symbol to the true North side, and the "S" symbol on the other side on a picture taken by a digital camera (and NE-SW, E-W etc.). Is there any digital Camera which is equipped to do so, like by having a "digital compass" like equipment within it. I am a field geologist, and strongly need this feature. Because, I daily take many pictures outside, and it is so hard and time consuming to note down every directions of every pictures as I take. A digital camera that could do it automatically and spontaneously could be very very helpful for me. Could someone give me an advice about it. Thanks
2012-04-07Mehmet
 Hi,
Does anyone know how to put geographic directions, such as "N" symbol to the true North side, and the "S" symbol on the other side on a picture taken by a digital camera (and NE-SW, E-W etc.). Is there any digital Camera which is equipped to do so, like by having a "digital compass" like equipment within it. I am a field geologist, and strongly need this feature. Because, I daily take many pictures outside, and it is so hard and time consuming to note down every directions of every pictures as I take. A digital camera that could do it automatically and spontaneously could be very very helpful for me. Could someone give me an advice about it. Thanks
2012-01-11ao7
 Useful article.

Found my way to JPEG-EXIF_autorotate which worked well for me.

Along the way I tried EXIFeditor and after a few attempts thought there might be an easier way (this is probably a more powerful programme, though fiddlier).

I'm using Vista with all the updates, Canon Powershot G9. Surprised there isn't something in ZoomBrowser or Picasa which does this.
2011-12-23Angkhana
 It's very helpful.
2011-12-20John Foster
 I just had an exchange of emails with a developer of a video viewing Mac and Win program I have orientation problems with.

He claims that EXIF orientation information is jpg images only, and not applicable to video.

He also claims that for video, Apple uses some ( as yet unspecified by him to me) non standard information for video orienation that he has no details from Apple about.

Is Apple just using EXIF for view finder convenience in the iPhone 4S and iPad 2 cameras?

Or is Apple not using EXIF at all as he claims?

Since I have no idea what I am looking at with various metadata browsing tools I have tried to decipher what Apple is doing, I wonder if anyone looking at this thread has any better ideas.

My last reply from him is shown below :
(email snipped)
 Video files (such as those from iPhones) are wrapped in QuickTime containers. They do not contain the traditional EXIF metadata that most people are familiar with in the context of JPEG photos. The "orientation" flag in video files is not as easy to find as it is in JPEG files. However, some video camera encoders (such as the iPhone's) use the Transformation Matrix in the Track Header atom (tkhd). Parsing this field, I can identify the rotations that are necessary to re-orient a video for proper display.
2011-12-18uk_rn
 hi.. im having problem with my iphone 4s pics... i cant rotate the pics when i copied it to my pc.. it sucks bigtime! i use to have th iphone4 and i never had a problem with...i've read your article cant actually grasp the meaning behind it... thanks
2011-12-06Fjord Lipweg
 Much to my befuddlement, there are webcams which, by default, reverse the video capture so that it displays on the screen like a mirror, and its snapshots also are. I wouldn't be surprised if these snapshots are encoded with flipped orientation.
 
2011-11-10John Foster
 I have an Apple iPhone 4S that I use for taking hockey game videos. The Apple Camera app works really well. There are two other camera apps ( CP Pro and Top Camera) I have been playing with. They both allegedly support a modest zoom capability that would be useful for me.
Is there a Mac OSX ( GUI, not command line in Terminal) utility that will show me the Orientation Flag values for files taken by these three camera apps after I download the files to may MacBook Pro?
I would like to prove to support forum folks for Plex and VLC that their software seems to be ignoring these flags.
2011-05-03Michael Lee
 I think it bears repeating that Photoshop and Lightroom do not rotate JPEGs losslessly. They acknowledge the rotation tag, but don't use them for rotation. As you can tell, I'm a firm believer in lossless rotation, and if a user does nothing else losslessly, he should at least rotate original JPEGs without incurring image loss right from the get go. Cal, I think you should have gone one step further and added these two (very popular) software in the "Beware" paragraph.
 Thanks Michael! -- I have now added a note to that section to remind readers of this fact.
2011-02-20Simon
 Hi again - a follow-up to my comments yesterday.

I suppose that if you want to have a complete uber-guide to EXIF Orientation, then you should really have 2 diagrams, though I guess that this is implied in my previous comment anyway.

Image 1 would be a graphical representation of EXIF Spec, which you already describe in your table, and which I guess is what everyone intuitively expects your existing diagram to be, but isn't. This would have the numbers 6 and 8 reversed, and could be described as something like:
"The VIRTUAL orientations of image 1 AFTER applying EXIF Orientation
(or how to display actual image 1 as virtually rotated images 2-8)"

Image 2 would then be your existing diagram, then described as something like:
"The ACTUAL orientation of image 1 BEFORE applying EXIF Orientation
(or how to display actual images 2-8 as virtually rotated image 1)"

Sorry if I've already said too much, but I'm sure you know what it's like to have an itch you can't scratch!

Cheers again, Simon.
 Finally had some time to take a good look at this. You're totally right. I thought for a while about the best way to represent this and I have decided to recreate diagrams showing the original "real-world" view (from the camera), the encoded JPEG view and finally the screen view (after rotation). I think this should be much clearer and hopefully I have the values correct now. Thanks so much for digging into this!
2011-02-19Simon
 Hi - I too scratched my head over 6 and 8 possibly being the wrong way round, but I now see that they aren't - maybe. It all depends upon what you are trying to depict.

The TABLE describes how a single image appears AFTER it has been rotated with various EXIF Orientations.

But the DIAGRAM shows what EXIF Orientations are applied to various camera rotations, that is to say it shows how an image appears BEFORE it is rotated.

This means that the table and the diagram are complete opposites of each other, and so each action in the table must be represented by its exact opposite in the diagram - and so they are!

So why are only 6 and 8 different? Because 2, 3, 4, 5, and 7 already ARE their own opposites - apply each one twice and you're back where you started. But 6 and 8, being 90 degree rotations, are not their own opposites but are instead EACH OTHERS opposites.

So if your "actual" image looks like F(8), then you need to apply an EXIF Orientation of 8 to display it like F(1).

But it is incorrect say that F(1) will look like F(8) after an EXIF Orientation of 8 has been applied to it.

The DIAGRAM is NOT a graphical representation of the TABLE, but it's not wrong either.

My head hurts now...

Many thanks for a fantastic site - I know my JPEGs are a world better because of it - Simon
 Perfect... Thank you very much for straightening out the ambiguity. I will look at fixing the images/table/text accordingly soon.
2011-01-04joh
 Great article! But figures 6 and 8 are incorrect and should be swapped, as mentioned in the comments. I've checked, and this is the way Eye of GNOME rotates the image.
 Thanks joh -- I will look into this again and update it if it looks like I've got it backwards :)
2011-01-03toto
 A question for you experts.

My old camera (Nikon Coolpix s6) has proper Exif Orientation support and my display program (Gnewview for linux) is perfectly showing rotated picture.

My new camera (Olympus Tough-3000) apparently is not supporting the orientation tag and I have to manually rotate pictures.

Now my question is: if I want to print out the pictures should I bring to the store the original ones or the rotated? In case of the old camera, it doesn't really matter because it was a virtual rotation while displaying, but with the new camera, it's a REAL rotation.

Any help is very much appreciated.
2010-10-23go4java
 Hi,
very clear and comprehensive summary of the EXIF "orientation" info.
Since I basically like the idea of getting all images AUTOMATICALLY rotated, I'm currently a bit upset about Sony's PS3: This box does NOT auto-rotate images according to their EXIF info; this applies to network streamed JPEG images, USB-connected images seem to work.
BR
2010-07-05Aldo
 Hi there,

Great post! I've been staring at the diagram above for the past hour and I'm pretty sure images 6 and 8 are labled incorrectly. Shouldn't image 6 actually be 8 and vise versa??

Thanks,
Aldo
 Good question... By "Row #0 is Right Side", it means that Row 0 in the encoded image is actually the right side of the captured scene. Similarly, Column #0 is the Top Side of the captured scene.
2010-05-22John
 Do you think the Kodak does it lossless?
2010-03-28gazzar
 @John, my Kodak camera definitely behaves differently to my Canon - I'm pretty sure the Kodak rotates it in the camera - I've never had to reprocess the image from my Kodak, but I have to run the Canon images through a lossless rotation program like this http://www.pilpi.net/software/JPEG-EXIF_autorotate.php
2010-03-21John
 Do you know if Kodak cameras actually rotate the image within camera.........
2009-12-31Cory
 Thanks for the info and nice graphic. It helped me to create an auto_rotate function in PHP. For anyone who is interested and knows PHP: http://www.mawhorter.net/web-development/simple-image-manipulation-in-php-rotate-resize-crop-flip-and-mirror-thumbnails-square-and-regular
 Thanks Cory
2009-11-29wim
 http://www.pilpi.net/software/JPEG-EXIF_autorotate.php

I just used this and it seemed to work fine. You don't feel like you're havng to install yet another program. Instead this only shows up when you need it.

grts
wim
 Thanks Wim
2009-11-27PJ
 Well, another example of thoughtless Microsoft programming - after all, don't use the picture and fax viewer, it is crap - and it does NOT rotate lossless, I checked specifically.
@Les: jhead does that among a number of other useful things such as correcting the EXIF time, etc.
2009-04-09Les
 Occasionally, my camera seems to be setting the EXIF orientation flag incorrectly, resulting in standard landscape shots displaying as portraits.

Can you suggest a program that will re-set the flag to 0 (or indeed any other value I may need to set it to) without touching any other data - in particular, without rotating the image data?

Thanks for a great series of articles.
Les
2009-02-28Kirsty
 Thanks for the article. I have a Canon camera with an orientation sensor and really wanted to view the photos correctly without messing with the image itself.

I've now downloaded IrfanView and am enjoying using that rather than Windows Photo Gallery.
 Glad to hear it!
2009-02-24Brian
 Yes I have followed the advice and this is the answer.
EXIF IFD0 @ Absolute x[00000014]
Dir Length = x[000C]
[Make ] = FUJIFILM
[Model ] = FinePix F470
[Orientation ] = 1
But photo uploads from camera to PC still does not "auto-rotate images"

http://www.dpreview.com/reviews/specs/FujiFilm/fuji_finepixf470.asp
JPEGsnoop tells me that the camera has Orientation - 1, but the above website says No Image Orientation.

Thanks
Brian
 If the camera is writing a "1" to the orientation flag, then one would generally assume that it has an orientation sensor. A value of "1" will indicate to software that there is no need to perform a rotation, so that explains what you are seeing. The real question is why the camera would set this orientation flag if it doesn't have a sensor...

I have confirmed that other images I've found on the web from this digicam set the Orientation flag to 1 irrespective of whether it was taken in landscape or portrait mode.
2009-02-24Brian
 Hi!
Digital Cameras with orientation sensors allow auto-rotation of portrait images.
Does my Fujifilm Finepix F470 have a built-in orientation sensor for auto rotation ? How can I find EXIF orientation flag? if it is in the camera Fujifilm Finepix F470 .
Thanks
Brian
 If you're using JPEGsnoop, have a look at the section starting with EXIF IFD0:
  EXIF IFD0 @ Absolute x[00000014]
    Dir Length = x[000B]
    [Make                                ] = FUJIFILM
    [Model                               ] = FinePix F700  
    [Orientation                         ] = 1
If the "Orientation" flag is shown, then generally the digicam has an orientation sensor built-in. In the above example (Fuji F700), we see that it does indeed have a sensor.
2008-11-12Jamie
 GQView on the linux side does honor the Orientation flag.

Note to Java programmers: Apache Sanselan can read exif data including this orientation flag when using that image library.

See: http://incubator.apache.org/sanselan/site/index.html

Eg.
IImageMetadata meta = Sanselan.getMetadata(image bytes[]);
if(meta instanceof JpegImageMetadata){
JpegImageMetadata metaJpg = (JpegImageMetadata) meta;
TiffField orientationField = metaJpg.findEXIFValue( TiffTagConstants.TIFF_TAG_ORIENTATION );
if(orientationField != null){
int orientation = orientationField.getIntValue();
if(orientation == 6){ //orientation right top
//rotate image 90 degrees here
}
}
}
 Thanks for the info, Jamie!
2008-10-30Chris Molloy
 Re: "The values 1-8 represent the following descriptions (as shown by utilities that support EXIF field decode) table" - there's a couple of typos in your table. As per http://www.exif.org/Exif2-2.PDF, the table should read:
1 = top, left
2 = top, right
3 = bottom, right
4 = bottom, left
5 = left, top
6 = right, top
7 = right, bottom
8 = left, bottom

The rotated 'F' diagram is correct, however.
 Great. Thanks for catching that (#2 & 4 have been corrected now).
2008-07-03Ramesh
 Posting is very useful and Thanks a ton :)

Just wanted to if there is any way to rotate a picture with out EXIF having a rotation info. Some intelligent algorithm which rotates automatically based on some common important objects like SKY, MOUNTAIN PEAKs..etc

Appreciate your help in this.
2008-06-09wjg
 should also mention that IE7 and Firefox do not support the orientation data either.
2008-02-21FyKnight
 I think your diagram is incorrect. 6 and 8 should be around the other way. The description is correct AFAICS. e.g. 8 says 'row 0 on the left side'. But in your diagram it is on the right side.
2008-01-22Davide Bolsi
 "Unless the camera were to encode the image right-to-left or know that you were taking a photo in a mirror, I don't see how these values will ever be used."

I agree, these values can be used for example with telescopes (or other optical devices) with a mirror diagonal on the optical path... but you will have to (be able to) properly set the camera in order to get the correct value.
In my opinion these values are aimed to different imaging devices like xray machines, slide scanners, etc
 Great point Davide!
2008-01-08Max
 Hi

Thanks a lot for the article, first !
Then i just would have like to know if the small soft given 2 posts below is a good solution in my case :

I'm usually using XnView to rotate my pictures.
However i recently got some taken by a Canon camera, meaning that the orientation exif flag is used. Thus XnView automatically rotates the pictures according to the flag, whereas Windows does not. But i would like to see the rotated pics in windows as well.
Thus i used the softawre advised (http://www.pilpi.net/software/JPEG-EXIF_autorotate.php) but i am not really certin of it to be the best solution :-)

Thanks for your advice !
 I have not used that particular tool myself, as I rely on DownloaderPro instead to do this function (plus the renaming and folder organization). I definitely think you can trust Downloader Pro as it has been widely used and well thought-out.
2007-08-31Tibor
 "While your digital camera may include an option to "auto-rotate images" due to the camera's orientation, this is ONLY used for the purposes of the LCD display on-camera."
My Kodak DX7440 does rotate the image, not only on its LCD display, but the file itself, the image is already rotated when I copy to PC.
 Definitely... I'm not sure why I wrote it as being only a LCD display function as that is not what I had intended to write -- the auto-rotate function is almost always just a "virtual rotation", not a real rotation of image content. Thanks for pointing it out -- I've clarified the sentence now.

 


Leave a comment or suggestion for this page:

(Never Shown - Optional)
 

Visits!