Andre's Technology Blog

  • Home
  • About
  • Electronics Projects (School/Hobby)
Posts Comments
  • Computer
  • Electronics
  • Embedded

Tagging JPEG Files

March 12, 2013 6 Comments

I have been researching how to tag my digital photos for easier categorization and searching. Sites like Flickr allowing tagging of uploaded photos, but I want the tags on the original files. And I want them embedded in the files, so that tags are retained when moving the files to another computer.  This write-up applies to JPEG files, although it sounds like TIFF files can also be handled in much the same way.

Terminology

Note that below I will refer to “metadata tags”, which are the labels used to identify individual pieces of metadata stored in a photo file.  These should not be confused with the categorization/search tags I want to add to the photos.  The categorization/search tags are sometimes referred to as keywords, and to avoid confusion that is how I will refer to them from now on (for the most part).

JPEG Metadata Summary

JPEG image files provide an area for applications to store metadata like title, date taken, shutter speed, etc.  There are several slots available, each of which holds a group of metadata tags.  The “APP1” slot holds metadata defined by the Exif standard.  The “APP14” slot holds metadata defined by the IPTC standard. The Exif metadata tags and the IPTC metadata tags do not overlap for the most part – they were designed to store different types of metadata (see references).  There is also a new XMP standard which can store the same metadata as Exif and IPTC.  It sounds like XMP was created as a replacement for Exif and IPTC, although all three types of metadata can co-exist in one file.  I  haven’t had any experience using XMP, and I am not sure if having XMP metadata complicates things.  For example, I am not sure how Windows or Flickr would react if keywords were present in both the XMP and the IPTC metadata.  Since cameras generally do not store XMP metadata, I am not going to worry about it.

The standard place to store keywords is in the IPTC slot under the “Iptc.Application2.Keywords” metadata tag.  So far, all of the software I have experimented with follows this standard.

References

  • http://www.photosecrets.com/metadata
  • http://graphicssoft.about.com/od/glossary/f/metadata.htm
  • http://help.zenfolio.com/customer/portal/articles/408313-exif-and-iptc-metadata
  • http://www.foto-biz.com/Lightroom/Exif-vs-iptc-vs-xmp
  • http://www.exiv2.org/metadata.html

Caution

Keep in mind that when you edit photo metadata you are actually editing the file.  If the photos are important to you, I encourage you to make backups before editing them. And when you are learning or evaluating editor software for the first time, I suggest you practice on copies of files that are OK to trash.

Operating System Support for Tagging

So far, I have been using Windows’ built-in metadata editor, and find it works well.  You get to the built-in editor by opening the JPEG file’s properties dialog box and going to the Details tab (this is on Windows 8 – the wording varies for earlier versions of Windows).  Here is a sample screenshot:

windows_properties_jpegtags

This capability existed at least as far back as Windows XP.  You can do batch editing by opening the properties dialog box while multiple files are selected.  The Windows built-in editor gets the job done, but it can be tedious if you need to go through many photos and tag or title them one by one.

Ubuntu 12.04’s file property dialog box also shows image metadata, but it does not allow you to edit the metadata.  So, unless there is some functionality I am missing, you will need to use 3rd party software for editing.

Tagging on the Command Line

Exiv 2 is a library and command line tool that allows you to manipulate photo metadata.  The Windows version of the command line tool can be downloaded here.  In Ubuntu, it can be installed using this command:

sudo apt-get install exiv2

To view a file’s metadata, use this command (the -pa option lists all metadata; otherwise only Exif metadata is displayed)

exiv2 -pa myphoto.JPG

To add a new keyword named mytag to myphoto.JPG:

exiv2.exe -M "add Iptc.Application2.Keywords String mytag" myphoto.JPG

More keywords can be added by adding extra “Iptc.Application2.Keywords” metadata tags.  Each keyword needs to appear under its own “Iptc.Application2.Keywords” metadata tag.  Addition of keywords using exiv2 is cumulative.  So, for example if you run these two commands in a row, myphoto.JPG will have two keywords (mytag1 and mytag2) in addition to any keywords that were already present:

exiv2.exe -M "add Iptc.Application2.Keywords String mytag1" myphoto.JPG
exiv2.exe -M "add Iptc.Application2.Keywords String mytag2" myphoto.JPG

Alternatively, you could have run this single command for the same results:

exiv2.exe -M "add Iptc.Application2.Keywords String mytag1" -M "add Iptc.Application2.Keywords String mytag2" myphoto.JPG

In Linux, you can use this command to tag all .jpg files in the current directory with mytag1 and mytag2:

find . -type f -iname \*.jpg -exec exiv2 \
  -M "add Iptc.Application2.Keywords String mytag1" \
  -M "add Iptc.Application2.Keywords String mytag2" "{}" \;

Other Tagging Software

There are many GUI programs out there for tagging photos and editing metadata.  I am on the lookout for a piece of open source software, but haven’t found one yet that exactly meets my needs.

Advertisement

Filed under Computer Tagged with iptc, jpeg, jpg, keyword, metadata, photo, tag

Recent Posts

  • Exploring Maximum Power Transfer with 3D Plots in Matlab
  • Ant Build Script for Android Icons
  • Tagging JPEG Files
  • Use “sdelete -z” when Shrinking a Windows Guest’s Virtual Hard Drive
  • VirtualBox – PowerShell Script to Start a Virtual Machine with the Maximum Number of Monitors

Archives

  • May 2015
  • December 2014
  • March 2013
  • December 2012
  • October 2012
  • August 2012
  • February 2012
  • December 2011

Categories

  • Computer
  • Electronics
  • Embedded

Meta

  • Register
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.com

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • Andre's Technology Blog
    • Already have a WordPress.com account? Log in now.
    • Andre's Technology Blog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...