Chappejw's Ubuntu related home on the net.
Adding Photo Right/Left Rotate from right click contextual menu
This is not the only way to add this functionality to Nautilus, however, this is a dead simple way to do it.
We will be adding a Rotate Right and Rotate Left functionality to the right click contextual menu in nautilus. You may select multiple JPEGs in a folder within nautilus and apply a right or left rotation to a selection of photos.
First, you will need 2 dependencies, jpegtran, and jhead. These will be used by bash scripts made available to nautilus.
1) try which jpegtran and which jhead. If these are missing you need to apt-get them or install them with your package manager.
2) cd ~/.gnome2/nautilus-scripts
3) using your favourite text editor create two files named rotate_right and rotate_left. These will be bash scripts acting as wrappers to the two utilities.
4) copy and paste the following script into rotate_right
while [[ -n "$1" ]]; do if [[ -f "$1" ]]; then jpegtran -rotate 90 -copy all \ -outfile "$1" "$1" #clear rotation/orientation tag jhead -norot "$1" fi shift done
5) copy and paste this script into rotate_left
while [[ -n "$1" ]]; do #if a file and not a dir if [[ -f "$1" ]]; then jpegtran -rotate 270 -copy all \ -outfile "$1" "$1" #clear rotation/orientation tag jhead -norot "$1" fi shift done
6) Make your scripts executable.
chmod +x ~/.gnome2/nautilus-scripts/rotate_right chmod +x ~/.gnome2/nautilus-scripts/rotate_left
6) Logout and back in to your system to reinitialize nautilus.
7) Now when you right click on one or more JPEG photos you will have a scripts menu option with 'rotate_right' and 'rotate_left'
8) Although this menu is available when scripts exist in ~/.gnome2/nautilus-scripts/ the actions will only work on JPEG images
9) Notes: According to the documentation on 'jpegtran' the rotations are lossless transformations, however I observed the file size increase slightly (a few dozen bytes) after rotating images. The image quality did not appear to be affected, but also no photo manipulation software recommends rotating images repeatedly as it could result in a loss in quality.