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
  • 1,489
  • 7
  • 47
  • 90
  • It should be noted that Google ended support for Picasa in 2016. – Burgi Mar 13 '18 at 11:19
  • You're right @Burgi, but I still think it's still a wonderful image viewer, and their face recognition is still amazing (I haven't found another standalone offline software that has such a powerful "automatically group photos by people" algorithm). – Basj Mar 13 '18 at 11:19

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
  • 1,489
  • 7
  • 47
  • 90
  • Can you explain in a little more detail what these applications do and why/how they solve your problem? Please see [How to recommend software](https://meta.superuser.com/questions/5329/how-do-i-recommend-software-in-my-answers). – Burgi Mar 13 '18 at 11:19
  • I added some details @Burgi. – Basj Mar 13 '18 at 11:26