Showing posts with label exiftool. Show all posts
Showing posts with label exiftool. Show all posts

Tuesday, May 5, 2009

You and Your Metadata

Image metadata is a confusing and obscure topic but, in at least a few respects, it's an important one, even for those who don't have to be meticulous about metadata (like stock photographers). Let's look at the very basics you should know about and manage.

First metadata, or data about data, are pieces of information that are embedded in an image file. The major image formats (JPEG, TIFF, etc.) all have the ability to store the various categories of metadata. Metadata that can be stored in an image file include things like EXIF (technical information such as camera, lens, exposure, etc. when the shutter was clicked), ICC color profile, IPTC information (caption, description, author, keywords, etc.), XMP information (updated and more flexible version of IPTC types of information), thumbnail images, image comment, and others. Most of these major categories of metadata consist of multiple pieces of information and sometimes subcategories of information.

Metadata is placed into an image by your camera, the image editing software you use, and even by you explicitly. The metadata is used by other software that manipulates or displays images, and by people and organizations that need or want information about the image such as what the picture is, when it was taken, where it was taken, who owns it, who has rights to use it, and so on. There is very good practical information about metadata and other topics related to best practices in digital imaging at updig.org. UPDIG is a coalition of the major players in the industry who are establishing guidelines, standards, and recommendations for issues of managing digital images.

Software, such as image editing programs, are usually a bit confusing about which metadata they are managing and how comprehensively they do it. For example, some software will let you place an IPTC copyright field but not the newer XMP copyright. Some image viewers don't handle XMP data but will display a metadata comment. Software will often include metadata that you have no interest in, potentially bloating the size of the image file.

If you haven't yawned your way away so far, let's get to some practical basics. Anybody putting one of their images on the Web or licensing it for use should, at the bare minimum, include copyright and contact metadata (as well as ICC profile). This makes it easier for someone to find you if they are interested in your image and it helps protect your rights of ownership. Section 1202 of the Digital Millennium Copyright Act of 1998 outlaws, and specifies penalties for, the removal or tampering of identifying copyright ownership information in digital works. So, not only do you get to state your claims of ownership for your image, but image thieves can be prosecuted for violating your ownership or tampering with your copyright metadata. This also may be helpful in defending your rights that Congress is attempting to erode with various "orphan works" legislative proposals intended to aid their fat-cat buddies who don't want to pay big penalties when they violate your copyright.

So, let's say our objective with image metadata is to store our copyright and contact information and remove bloating metadata we have no interest in. One easy and comprehensive way to do this is through the use of Phil Harvey's excellent ExifTool, a Perl library that's available as a command-line tool on Windows and Mac platforms. I won't attempt to provide an overview of everything this powerful tool can do, but I'll give you an example of how I use it to achieve our goals of ripping out extraneous metadata and adding in our contact and copyright information.

Let's say you have an image named example.jpg and you wish to view the metadata that's already resident in the file:


exiftool -G1 -s example.jpg


This will display a (long) list of metadata names and values. It's quite interesting to see all the data stored in what looked like an ordinary image file.

To change the metadata to suit our purposes, we can use a lengthy list of command parameters or, more manageable, use a separate file with all of our command parameters that we tell ExifTool to use:


exiftool -@ mymetadata.txt example.jpg


The "-@" parameter tells ExifTool that the next parameter contains a list of all the command parameters we want to use against our image file. You can get my sample at http://pduncan.com/extras/mymetadata.txt. Edit it so it uses your information rather than mine and try running it on a file. Then use ExifTool to display the updated metadata using the command shown earlier.

If you notice at the bottom of the mymetadata.txt parameter file, I add the copyright statement into 4 places: EXIF, IPTC, XMP, and comment. This maximizes the chance that a given image viewer will recognize at least one of those.

The ExifTool command can, of course, be used to update multiple files:


exiftool -@ mymetadata.txt *.jpg


ExifTool is not the only way to do this work, and perhaps it's not the best for your workflow. The important thing is to find a way to tag your images appropriately that's easy and automatic for you.

Note we haven't covered image-specific metadata like captions, descriptions, keywords, etc. That's a whole other topic entirely.

Of course, none of what we covered here changes the need to register your images with the Copyright Office. It's easy, it's inexpensive, and it gives you the broadest set of options if you need to resort to legal action to protect your rights.

Update 6 April 2010: In a comment, Ed notified us of ExifTool updates that changed some of the example's parameters and he showed how to incorporate the file CreateDate to use as the copyright year. The above entry and example parameter file have been updated to incorporate the changes. Thanks Ed!

Monday, August 18, 2008

Part 5: Putting It All Together

In previous posts, we've looked at the Canon G9 point-and-shoot camera's vignetting, geometric distortion, and chromatic aberration. We've also looked at strategies for addressing these issues, primarily using the fulla command from the hugin panorama photo stitcher package.

The fulla command doesn't have a nice friendly GUI interface but it does allow us to put together arbitrary corrections to be applied to large numbers of images without a great deal of effort. Each of the fulla corrections we've explored in previous posts can be combined into a single command addressing vignetting, geometric distortion, and chromatic aberration.

Your workflow sequence is very important. The corrections we've been discussing should be applied to the images before any cropping, resizing, etc. have been done. I always shoot raw so I use ACR or some other tool for "developing" the image to set the correct initial tonality, color temperature, etc. and then export the image in 16-bit TIFF format (lossless unlike JPEG). I apply the image corrections and then bring the corrected version into Photoshop for subsequent processing.

Let's start with a hypothetical file shot on the Canon G9 at 7.4 mm and f/4, and processed from the raw CR2 file into a 16-bit TIFF file called example.tif. To apply my standard corrections for vignetting, geometric distortion, and chromatic aberration, I would use the following command:

fulla -c 1.0398:-0.1155:0.1954:-0.1605 \
-g 0.028:-0.0871:0.0521:1.007 \
-r 0:0:0:1.00024 -b 0:0:0:1.00041 example.tif

(The '\' characters indicate arbitrary line breaks for formatting here. This is actually all one command line.)

The "-c" option gives the polynomial coefficients for correcting vignetting, the "-g" option gives the polynomial coefficients for geometric distortion correction, and the "-r" and "-b" options provided the polynomial coefficients for transverse chromatic aberration correction. (But you already knew that.)

When fulla is done crunching the numbers, it outputs a file with a "_corr" filename suffix. So our example correction would create a new file called example_corr.tif. It will look substantially better than the original with the corrections applied.

Naturally you don't want to have to type in that command every time you process a file so you can create a MSDos batch command file (on Windows) or a Bash script (on Unix systems) to generalize it. Let's say we want to correct arbitrary numbers of files with one command. We can create a batch file like this:


for %%f in (%1) do \
fulla -c 1.0398:-0.1155:0.1954:-0.1605 \
-g 0.028:-0.0871:0.0521:1.007 \
-r 0:0:0:1.00024 -b 0:0:0:1.00041 %%f

(Once again, this should be all on one line in the real batch file.) Assuming you named this something like G9_74_4.bat (because it's only useful for the G9's 7.4 mm f/4 images), you can process all the TIFF files in a directory with a single command:

g9_74_4 *.tif

Unix, Linux, Mac users can create analogous script files using for iterations to do precisely the same thing.

I must mention something about the fulla command here: it's flaky and not mature in some regards. One frustration is that, when it outputs a corrected image, that corrected image has its metadata stored in an unconventional way that is not visible to Photoshop and many other applications. If you're running any kind of responsible workflow, this is not good, but there is a way around the problem.

ExifTool by Phil Harvey is a superbly-done high-function image metadata management tool. It has an extraordinary number of capabilities and it handles them well. If you download the tool, you can use it to save your EXIF (and other metadata) from your image, apply your fulla corrections, and then restore the original metadata in standard format. For example, you can save the metadata for all TIFF files in a subdirectory with this command:

exiftool -o %f.mie -ext tif .

Process your files using the fulla corrections and then restore the metadata to the corrected files.

exiftool -overwrite_original -tagsfromfile %-.5f.mie \
-ext tif .

You can even skip the intial save to MIE file (Meta Information Encapsulation) and simply rewrite the original file's metadata over the fulla output file:

exiftool -overwrite_original -tagsfromfile %-.5f.%e \
example_corr.tif


Finally, if you're really ambitious and have Perl programming skills, you could use the Perl Image::ExifTool package to determine the focal length and f-stop for the image and then do a table lookup to determine which of the fulla option parameters to use. I've done a rudimentary job of this just for the subset of camera settings I almost always use for the Canon G9.

If all these seems like a lot of trouble to correct the occasional image, you're right. It's most worthwhile if you routinely have large numbers of images you wish to optimize; then the use of fulla in batch or script files makes more sense.

If you only do occasional corrections, want something a bit easier to deal with, or want a commercial solution, stay tuned. Next up we'll glance at a couple of alternatives for correcting images that don't require all the up-front work we've been slogging through here.

Vignetting Revisited

After enduring a little confusion and frustration in correcting some images from my Canon G9 camera, I investigated a little more and found ...