JPEG Autorotate for Linux (Obsolete)

Obsolete. This page has not been updated in some years. If you know a project that has properly implemented autorotating JPG’s based on EXIF metadata, please tell me and I will add a link here.

I currently use a program called digikam, which does the rotating automatically when downloading the pictures from the camera. What’s below is for reference.

KDE (or actually, Konqueror in any window manager)

Download now!
Ver. 1.0 (2 kb)

Instructions: Download to your home directory (usually /home/{username}/) and unzip, that will create the necessary files in all the right places. For the script to work, you will need to have at least jhead installed, and possibly jpegtran. Warning: On July 2006 at least Ubuntu 6.06 LTS/dapper didn’t have a recent enough version of jhead to rotate also the thumbnails. If you want your thumbnails rotated, I suggest you get the Pre-built Linux executable from jhead’s home page and change the paths in the scripts.

The only way this reacts to mouse clicks is by doing its job, unlike the Windows version (there’s no dialog reporting of the progress). If can show me a way to give the user some feedback during the rotating process, I would appreciate it.

Tip: if you launch konqueror in a console window, when you do the rotating in konqueror, you can see the progress of the rotating in that console window.

How I did it

Note: I’m assuming that your per-user KDE settings are stored at ~/.kde/ – check your home directory (~) to find out if it’s something else and adjust the script locations accordingly.

  1. Install jhead (and if needed, exiftran), if you don’t have it (e.g. if typing jhead in a console says something like “command not found”). In Ubuntu (and probably in Debian, too) the name of the package for exiftran at least is exiftran, so just do: sudo apt-get install exiftran

  2. Rotating individual files: Create a text file in the location ~/.kde/share/apps/konqueror/servicemenus/jpeg-exif_autorotate.desktop with the following contents:

    [Desktop Entry]
    [Desktop Action JPEG-EXIF_autorotate]
    Exec=jhead -autorot %f
  3. Rotating all files in a directory. Create a text file in the location ~/.kde/share/apps/konqueror/servicemenus/jpeg-exif_autorotatedir.desktop with the following contents:

    [Desktop Entry]
    [Desktop Action JPEG-EXIF_autorotatedir]
    Name=Auto-rotate all files in directory and subdirs
    Exec=jhead -autorot %f/*
  4. Rotating all files in a directory and in all subdirectories. Create a text file in the location ~/.kde/share/apps/konqueror/servicemenus/jpeg-exif_autorotatedir_recursive.desktop with the following contents:

    [Desktop Entry]
    [Desktop Action JPEG-EXIF_autorotatedir_recursive]
    Name=Auto-rotate all files in dir and in subdirs
    Exec=find %f -iname "*.jpeg" -type f -exec /home/a/jhead/jhead -autorot {} \;
    Exec=find %f -iname "*.jpg" -type f -exec /home/a/jhead/jhead -autorot {} \;

That should do it (you might want to customize the Icon entry). Now right click any folder or JPEG file and look in the Actions submenu. I learned all this reading an O’Reilly Linux Desktop Hacks article, and that’s where you should go to for further information.


While making JPEG-EXIF autorotate platform independent doesn’t seem to be possible (there’s no such thing as Java for creating right-click menus in different OSes), this is where provide instructions on how to do the same with different graphical desktop environments/operating systems. So far I only have KDE – I’m mostly a GNOME user myself, but I found the instructions for KDE first.

Rotating the files in a directory and its subdirectories happens in Linux by issuing the command ‘find . -iname “*.jpg” -type f -exec jhead -autorot {} \;’. This assumes that you have jhead installed in your system, and if you have anything older than v.2.5 (?) then I would recommend upgrading it to also get the thumbnails rotated.

Comments and feedback