24
\$\begingroup\$

I have several thousand images taken with a GoPro that are upside-down.

I'm looking for a way, an app really, that can flip them all, 180 degrees, in one operation.

I have looked at every option in GoPro's own software, but do not find this for stills only. You can rotate while making a video, but I want to keep the individual images.

I'm on Windows.

\$\endgroup\$
2
  • \$\begingroup\$ Related, and very relevant: Are “Windows Photo Viewer” rotations lossless? \$\endgroup\$
    – scottbb
    Commented Sep 2, 2016 at 22:15
  • \$\begingroup\$ jpegtran is the way to go. it can rotate and/or flip JPEGs losslessly, and is easy to call from a script because it's a CLI app. \$\endgroup\$ Commented Sep 5, 2016 at 5:37

13 Answers 13

35
\$\begingroup\$

I would recommend any of the applications from this list at JPEGclub.org, which develops and maintains software for the Independent JPEG Group. They have a free piece of code called jpegtran which can do some basic transformations (like rotation) without re-encoding the image.

Rotating images the "naive" way (rendering to a bitmap, reorienting the bitmap, and re-saving) can result in increased JPEG artifacts — and bigger files with less useful data.

The list above contains software which is known to do it "the right way". Other software may as well (perhaps using a different code base), but ImageMagick is not one of them, unfortunately. But, as of August 2016, there are 87 different options for many different computing platforms, including Windows.


Note from comments: the OP used this loop based on this answer:

FOR %f IN (.\Src\*.*) DO jpegtran.exe -rotate 180 %f .\Rotated\%~nxf

with good results.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Note that lossless rotation works only if each dimension of each image is a multiple of 16 pixels – 8 if chroma subsampling is not used. Otherwise either the excess pixels are lost or the image will be padded with a border. For example, 1080 is not a multiple of 16! \$\endgroup\$
    – Gnubie
    Commented Sep 2, 2016 at 9:53
  • 3
    \$\begingroup\$ I second the recommendation of jpegtran; even better, if you care about keeping the EXIF's thumbnail and Orientation tag consistent, you might consider exiftran which is unaccountably absent from the JPEGclub list, but is lossless. My command (on Linux) for this would be exiftran -i -1 *.jpg or find . -name '*.jpg' -print0 | xjobs -0 -l 10 exiftran -i -1; this will need adapting for Windows shell. \$\endgroup\$ Commented Sep 2, 2016 at 9:59
  • \$\begingroup\$ @Toby Good addition. Many (most?) of the listed programs will also preserve and update metadata, which is one reason I recommend one of them instead of just jpegtran directly. \$\endgroup\$
    – mattdm
    Commented Sep 2, 2016 at 13:26
  • \$\begingroup\$ Thank you! I used jpegtran on Windows. The rotate 180 is exactly what I needed. I put exact batch command in the question for future ref. \$\endgroup\$
    – DTRT
    Commented Sep 3, 2016 at 20:56
  • \$\begingroup\$ @Johns-305 Glad I could help. On the edit to the question, see meta.photo.stackexchange.com/questions/1601/… \$\endgroup\$
    – mattdm
    Commented Sep 4, 2016 at 1:39
12
\$\begingroup\$

On Windows you can do it without any extra software in TWO operations. Select the files you want rotated in file Explorer, right click and do "rotate right" (or left) twice. It will be done losslessly if the image permits (eg, the dimensions are not "funny").

\$\endgroup\$
3
  • \$\begingroup\$ What are "funny" dimensions? Why would a photo's dimensions prevent lossless rotation? \$\endgroup\$
    – scottbb
    Commented Sep 2, 2016 at 21:54
  • 2
    \$\begingroup\$ After reading Are “Windows Photo Viewer” rotations lossless?, I understand now. Both dimensions need to be a multiple of 8 in order to be losslessly rotated. \$\endgroup\$
    – scottbb
    Commented Sep 2, 2016 at 22:17
  • 1
    \$\begingroup\$ This is the best answer. I joined the site just to upvote this. \$\endgroup\$
    – fi12
    Commented Apr 17, 2018 at 22:41
10
\$\begingroup\$

You could use ImageMagick with the rotate option:

convert image.jpg -rotate 180 result.jpg

You should be able to apply this command to multiple files, depending on your environment.

\$\endgroup\$
1
  • 11
    \$\begingroup\$ Note though that this will reencode the jpeg, losing quality. \$\endgroup\$
    – mattdm
    Commented Sep 1, 2016 at 16:40
5
\$\begingroup\$

You can use xnview on windows, which has some batch mode processings and also, for a simple rotation of images, have the option to rotate images based on the exif data.

Select all the images (even the correctly oriented ones! It will know they are already well oriented), "rotate based on exif" and it will do it (without recalculating the jpg, so with no loss of quality).

Like they say on http://newsgroup.xnview.com/viewtopic.php?t=1420 :

To do this, you select all your images and select "Tools > JPG Lossless tranformations" (or dropdownlist of symbol 'JPG lossless transformations' in toolbar). In the dialog check the button with "EXIF" on it and then press "Go". XnView will permanently rotate the images based on the EXIF orientation flag.`

And for next time, if you have a recent enough gopro, you may want to check it's feature as well: https://gopro.com/support/articles/what-is-auto-image-rotation

\$\endgroup\$
1
  • \$\begingroup\$ Does the GoPro actually save the correct EXIF orientation data? The Hero4 / Session have an orientation sensor, but I don't think any of the older models do. \$\endgroup\$
    – vclaw
    Commented Sep 1, 2016 at 23:43
4
\$\begingroup\$

Assuming your photos are in JPEG format, I'm quite partial to JPEGCrops, a simple and free tool for lossless batch processing of images.

You can crop to specific aspect ratios, and/or rotate.

\$\endgroup\$
0
4
\$\begingroup\$

FSViewer is a useful program that can do that.

Open up the folder where the images are, select all that you want to rotate, hit F4 and go to the 'Batch Convert' tab in the window that opens up. Click 'Advanced Options' on the bottom right, go to the 'Rotate' tab. Check 'Flip / Rotate', then 'Rotate', then select '180' below and hit OK. Set where you want these saved and hit 'Convert'.

Edit: a quicker and more painless way is just to select all the images you want and hit twice 'Rotate right and save' in the toolbar. Should be non-destructive for JPEGs.

\$\endgroup\$
0
4
\$\begingroup\$

May I suggest the batch mode of Irfanview, which only runs on Windows. Irfanview is also good for simple edits, but it is no GIMP.

Once installed, select "File | Batch Conversion/Rename". From there it gets a bit tricky, you need to select all the files, you need to specify a destination folder, and you need to click on the Advanced Button to see Advanced options. It can rotate +/-90°, but to do 180° you will need to pick fine rotation on the far right and enter in 180°. Note that you can also resize them, change JPEG quality, and rename them.

You can also do it rather quickly by staying in the GUI and using the keyboard. Open any file in the folder of pictures. Press 'R' two times to rotate twice. Then press Ctrl-S to save. Two windows will show up, one your typical file dialog, and a second one for JPEG compression (if GoPro's default format is JPEG). I would make sure the Quality Factor is at least 90%. Then save the file; you should be able to press the Tab key or Alt-S to save. An "Are you sure" type dialog might show up (might be able to turn that off). Then, just press the Space bar to advance to the next file in the folder. If you have 50+ files, the batch might be quicker. Ten files, I just do the above.

Key thing to Irfanview is that its like Blender, it doesn't ask you if you want Save if you modify an image.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ That will do a lossy rotation - as its rotating them, then resaving the JPEG, so you are losing quality. In IrfanView, better to use the "JPEG Lossless rotation" feature (Shift+J). Note you can use the thumbnail view to select all of your images, then rotate them all at once. \$\endgroup\$
    – vclaw
    Commented Sep 1, 2016 at 23:24
  • 1
    \$\begingroup\$ @RocketFeathers - Irfanview is the easiest tool with which to do this losslessly in a Windows environment. But like vclaw says, it's much better to use the "JPEG Lossless Rotation" to do it. Edit your answer to reflect that and I will upvote it. \$\endgroup\$
    – Michael C
    Commented Sep 1, 2016 at 23:43
  • \$\begingroup\$ "it doesn't ask you if you want Save if you modify an image." - This can be changed in Options > Properties/Settings... > Ask to save changes on program exit. \$\endgroup\$
    – MrWhite
    Commented Sep 4, 2016 at 8:59
4
\$\begingroup\$

With windows you can mark all if them in the explorer then right click and choose rotate clockwise. Do this two times and your pictures are now rightly orientated.

\$\endgroup\$
2
\$\begingroup\$

Do you know GIMP? There is a plugin called BIMP that lets you perform the same operation on a set of images, using a graphical interface. You can easily install it using the official installer for Windows.

You can also re-save them in another format or with different compression ratio to avoid big quality loss.

Disclaimer: I made it :D

\$\endgroup\$
0
1
\$\begingroup\$

ImageMagick is a set of command line tools that operate on images, and you can combine those tools with basic Unix shell commands to apply the same command to a set of files. There are a lot of good examples at How to rotate all images in a directory with imagemagick?.

\$\endgroup\$
0
1
\$\begingroup\$

I personally use Adobe Lightroom. Images can easily be batch roted and edited, just select the images you would like to rotate, right click, and select the option to transform the images by rotating 180 degrees.

If you are consistently working with thousands of images that require batch processing, particularly if it is more complex than rotating - like adjusting color or exposure, then LR is probably a solid investment.

I don't like that Lightroom is closed source, costs money, and won't run on Linux systems. However, I have found that the features far exceed what is available for free.

\$\endgroup\$
0
\$\begingroup\$

You could use LiveBlox and build a pipeline to allow rotating of the image. The demo version on http://liveblox.org has a rotation block so will allow this to be done.

There is a tutorial https://www.youtube.com/watch?v=kY0e5msQuiU that shows how to make the batch image resizer, you'd just need to replace the fixed size resize with the rotator to do the rotation.

This would allow you to work on each image with a single click.

\$\endgroup\$
0
\$\begingroup\$

$ for F in *jpg; do convert -rotate 180 $F "$(basename $F .jpg)_R.jpg" && echo "Done $F"; done

Explanation: *for F in .jpg portion of the command assigns the filename to a variable, which can be recalled later to rename the file to [original file name}_R.jpg

the "do convert -rotate 180" tells the computer that you would like your images converted, by being rotated 180 degrees.

The "$(basename $F .jpg)_R.jpg" portion of the command indicates the new file name.

The && tells the computer than an additional command is coming, but that the computer is only allowed to execute the command if the previous (rotating and renaming) command was successful.

echo "Done $F" tells the computer to tell you ("echo" to you) that each file has been successfully rotated. $F sub-portion of the command is recalling the initial filename variable, so the output will probably say something to the effect of "Done file1.jpg"

And, one needs sh/csh/bash for this piece to work.

\$\endgroup\$
5
  • 5
    \$\begingroup\$ That's possibly working, but without an explanation, it's not a good answer. Please explain in what context this solution if applicable. \$\endgroup\$
    – null
    Commented Sep 1, 2016 at 21:17
  • 1
    \$\begingroup\$ Is this an expansion of null's answer using ImageMagick? \$\endgroup\$
    – MikeW
    Commented Sep 1, 2016 at 23:05
  • \$\begingroup\$ This doesn't work as expected if there are already *_R.jpg files in the directory. \$\endgroup\$
    – pts
    Commented Sep 2, 2016 at 8:55
  • \$\begingroup\$ Thank you for the clarification, I'm not sure if installing a UNIX shell on windows is a practical approach, but it is an approach no less. \$\endgroup\$
    – null
    Commented Sep 2, 2016 at 10:16
  • \$\begingroup\$ pts, you can change the _R.jpg to whatever you want (like "_rotated.jpg"). You are correct that this will be problematic if you already have _R.jpg files in the directory. \$\endgroup\$
    – SB Ph.D.
    Commented Sep 2, 2016 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.