Tagging JPEGs

Purpose: a simple way of adding text tags to JPEG images, in batches, selecting them in a graphical way. We prefer, of course, do avoid application-specific programs and just use the normal things such as a filemanager.

Put this (shell) script tagjpeg somewhere on the path used by KDE, e.g. in $HOME/bin.

#!/bin/sh

new="`mktemp`"
xterm -e vi "$new"

for f in "$@"
do
        tags="`mktemp`"
        jhead -cs "$tags" "$f"
        cat "$new" >>"$tags"
        jhead -ci "$tags" "$f"
        rm "$tags"
done

rm "$new"

Put this file tagjpeg.desktop into $HOME/.kde/share/apps/konqueror/servicemenus/.

[Desktop Entry]
ServiceTypes=image/jpeg
Actions=tagjpeg
[Desktop Action tagjpeg]
Name=Tag JPEG image
Terminal=1
Icon=background
Exec=tagjpeg %U

Then, if you select a JPEG image or a group of JPEG images in Konqueror, the right-click menu `Actions' group should contain `Tag JPEG Image', which causes a terminal window to pop up (make sure you've got xterm, or change the script to konsole or something) with the vi editor (modify this in the desktop file if wanted), into which you can type and save the new lines of tags. On exiting the editor, the images will have their original tags written back but with the new ones appended.

Clearly the core of all this is the jhead command, which seems to be popular among OS distributions. http://www.sentex.net/~mwandel/jhead/.


Page started: 2009-11-03
Last change: 2009-11-03