2

I made a photo with my Samsung phone and:

  1. The orientation is good when displayed on the phone

  2. The orientation is good when displayed in Picasa (this means the JPG files contains the right orientation metadata!)

enter image description here

  1. The orientation is wrong when displayed in Windows 7 Explorer thumbnail:

enter image description here

  1. The orientation is wrong when displayed in Windows 7 Image viewer:

enter image description here

One solution could be to "forget about Windows 7's built-in image viewer", and use another better image viewer, but I don't want this.

I would like to permanently rewrite the JPG files (and overwrite them) with the new good orientation, in bulk for hundreds of JPG files, i.e. like if I clicked manually hundreds of times on these buttons when viewing the images one after another:

enter image description here

but automatically, with a script.

How to do this?

Note: I know it might not be lossless, but still I would like a permanent rotation so that the default Windows 7 image viewer see them with the good orientation.

Note 2: here is the source file, available for download.

Basj
  • 2,143

1 Answers1

2
  • Download jpegtran from here: http://jpegclub.org/jpegtran/. Direct link to jpegtran.exe. You won't need to run this .exe yourself, but it will be necessary for jhead (see next point) to work. jpegtran is a tool that can perform, according to its home page, "lossless rotation and related transforms".

  • Download jhead from here: http://www.sentex.net/~mwandel/jhead/. Direct link to jhead.exe. jhead is an "Exif Jpeg header manipulation tool", that will read the orientation metadata inside the JPG, and pass it to jpegtran for rotation, if necessary.

  • Just run

    jhead -autorot *.jpg
    

and that's it!

This question was useful, I added details to make it easy to use from the perspective of a Windows user.

Note: Sometimes, an error can happen for some file, preventing the processing to continue for the other files, this is annoying. Then for /r %i in (*.jpg) do jhead -autorot "%i" can help in this case. [If it's in a batch file, use for /r %%Mi in (*.jpg) do jhead -autorot "%%i"]

Basj
  • 2,143