ExifTool is a Perl module with an included application script that allow you to read and write meta information in image files. It reads EXIF, GPS, IPTC, XMP, GeoTIFF, ICC Profile and Photoshop IRB meta information from JPG, JP2, TIFF, GIF, CRW, THM, CR2, MRW, NEF, PEF, ORF and DNG images. ExifTool also extracts information from the maker notes of many digital cameras by various manufacturers including Canon, Casio, FujiFilm, Minolta/Konica-Minolta, Nikon, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Sanyo and Sigma/Foveon.
ExifTool has the ability to write EXIF, GPS, IPTC, XMP and MakerNotes meta information to JPEG, TIFF, GIF, CRW, THM, CR2, NEF, PEF and DNG images. When writing, ExifTool preserves the original file by adding "_original" to the file name. You should keep a copy of the original, or thoroughly validate the new file before erasing the original. Read here for some ramblings on the subject of writing meta information.
Currently, ExifTool supports Asahi, Canon, Casio, Epson, Foveon, FujiFilm, Konica-Minolta, Leica, Minolta, Nikon, Olympus, Panasonic, Pentax, Sanyo and Sigma maker notes, but support for new types can easily be added by editing the ExifTool modules.
The ExifTool support modules are very readable. The format for these files is documented in Image/ExifTool/README.
If you make any useful new additions, e-mail me the file so I can add the functionality to the distributed version.
Drop me a note if you find ExifTool useful. My e-mail address is in the README file. Thanks.
File Name 113_1366.JPG Camera Model Name Canon EOS DIGITAL REBEL Shooting Date/Time 2003:10:31 15:44:19 Shooting Mode Program AE Tv(Shutter Speed) 1/60 Av(Aperture Value) 5.6 Metering Mode Evaluative Exposure Compensation 0 ISO Speed 100 Lens 18.0 - 55.0mm Focal Length 55.0mm Image Size 2048x3072 Quality Normal Flash On Flash Type Built-In Flash Flash Exposure Compensation 0 Red Eye Reduction Off Shutter Curtain Sync 1st-curtain sync White Balance Auto Focus Mode AI Focus AF Contrast +1 Sharpness +1 Saturation +1 Color Tone Normal File Size 811KB Image Number 113-1366 Drive Mode Continuous shooting Owner's Name Phil Harvey Camera Body No. 0560012345
NAME exiftool - print/modify meta information in image files SYNOPSIS exiftool [OPTIONS] [-TAG[[+-<]=[VALUE]] or --TAG...] FILE ... DESCRIPTION Prints or writes information for specified tags from/to listed files. -TAG specifies the name of a tag to extract or --TAG to ignore. FILE may be an image file name, a directory name, or - for the standard input. Supported file types are JPG, JP2, TIFF, GIF, THM, CRW, CR2, MRW, NEF, PEF, ORF and DNG. -TAG=VALUE sets the value of a tag, and -TAG= deletes a tag. -TAG+=VALUE adds a value to a list without replacing existing values, and -TAG-=VALUE deletes a specific value from a list. Use "-TAG<=FILENAME" to set the value of a tag from the contents of a file (the quotes prevent shell redirection). The tag is written to all groups where it is valid if no group is specified. A special (and powerful) variation of this syntax, -AllTagsFromFile=SRCFILE, allows all writable tags to be set from information in another file. Any tag name may be prefixed by a group name to specify the location (ie. -GROUP:TAG). While reading information, any group name in family 0 or 1 may be used. For writing, valid groups are EXIF, GPS, IPTC, XMP, MakerNotes, or any EXIF IFD name. Currently, EXIF, GPS, IPTC, XMP and MakerNotes tags may be written to JPG, TIFF, GIF, CRW, THM, CR2, NEF, PEF and DNG files. Be sure to verify that the new file is OK before erasing the original (which is renamed to FILE_original). OPTIONS -list - list all valid tag names -listw - list all writable tag names -group# - list all tag groups for family # -ver - print version number and exit -a - allow duplicate tag values (otherwise only last value displayed) -b - output requested data in binary format -d FMT - set date/time format (consult strftime manpage for FMT syntax) -D|H - show tag ID number in Decimal or Hexadecimal -e - print existing tags only -- don't calculate composite tags -E - escape characters in output values for HTML -f - force printing of tags even if their values are not found -g[#] - organize output by tag group (-g0 assumed if # not specified) -G[#] - same as -g but print group name for each tag -h - use HTML formatting for output (implies -E option) -i DIR - ignore specified directory names -l - long output (2-line Canon-style output) -m - ignore minor errors (allows writing if minor errors occur) -n - don't convert values for printing -o FILE - output file or dir name for writing (otherwise edits input file) -p FILE - print in format specified by file (ignores other format options) -P - preserve date/time of original file when writing -r - recursively scan subdirectories (only useful if "file" is a dir) -s - short format (add up to 3 -s options for even shorter formats) -S - print tag names instead of descriptions (same as two -s options) -t - output tab-delimited list of description/values (database import) -u - extract values of unknown tags (2 to extract from data blocks) -U - also extract unknown from data blocks (same as two -u options) -v[#] - verbose messages (# may be 1-4, higher is more verbose) -w EXT - write console output to file with EXT extension for each image -x TAG - exclude specified tag (may be many -x options) -z - extract information from .gz and .bz2 compressed images
The -g and -G options organize tags into different families of groups based on the specified family number. Currently, 3 families of groups are defined:
Family Group Names 0 (General Location) Composite, EXIF, ExifTool, File, GPS, GeoTiff, ICC_Profile, IPTC, MakerNotes, Photoshop, PrintIM, XMP 1 (Detailed Location) Canon, CanonCustom, CanonRaw, Casio, Composite, ExifIFD, ExifTool, File, FujiFilm, GPS, GeoTiff, GlobParamIFD, ICC-chrm, ICC-clrt, ICC-header, ICC-meas, ICC-view, ICC_Profile, IFD0, IFD1, IPTC, InteropIFD, MakerUnknown, Minolta, Nikon, NikonPreview, Olympus, Panasonic, Pentax, Photoshop, PrintIM, Sanyo, Sigma, Sony, SubIFD, XMP, XMP-aux, XMP-crs, XMP-dc, XMP-exif, XMP-pdf, XMP-photoshop, XMP-tiff, XMP-xmp, XMP-xmpBJ, XMP-xmpMM, XMP-xmpRights 2 (Category) Author, Camera, ExifTool, Image, Location, Other, Printing, Time, Unknown
# print common EXIF information from "dir/a.jpg":
exiftool -common dir/a.jpg# print all EXIF information from "dir/a.jpg" sorted by group (for group family 0):
exiftool -g dir/a.jpg# print ImageSize and ExposureTime tags without colon separators:
exiftool -s -ImageSize -ExposureTime b.jpg# print standard Canon information from 2 image files:
exiftool -l -canon c.jpg d.jpg# save common EXIF information for each file in the "pictures" directory and all subdirectories into files with the same names as the images but with a ".txt" extension:
exiftool -r -w .txt -common pictures# extract thumbnail image from "image.jpg" and save it to the file "thumbnail.jpg":
exiftool -b -ThumbnailImage image.jpg >thumbnail.jpg# recursively extract JPG from all Canon RAW files in the current directory, adding "_JFR.JPG" for the name of the output JPG files:
exiftool -b -JpgFromRaw -w _JFR.JPG -r .# extract preview image from JPG write it to "preview.jpg" (this is the 1536x1024 review image for the Canon 300D):
exiftool -b -PreviewImage 118_1834.JPG > preview.jpg# print formatted date/time for all JPG files in a directory:
exiftool -d "%r %a, %B %e, %Y" -DateTimeOriginal -S -s *.jpg# extract image resolution from IFD1:
exiftool -IFD1:XResolution -IFD1:YResolution
# set comment in file (replaces any existing comment):
exiftool -comment="This is a new comment" dst.jpg# remove comment from all JPG files:
exiftool -comment= *.jpg# replace existing keyword list with two new keywords (EXIF, editor):
exiftool -keywords=EXIF -keywords=editor dst.jpg# add a keyword (word) to the current list of keywords:
exiftool -keywords+=word dst.jpg# delete only the specified category (xxx) from all files in directory:
exiftool -category-=xxx dir# set all writable tags from information in another file:
exiftool -AllTagsFromFile=src.crw dst.jpg# set thumbnail image from specified file (note: quotes are neccessary):
exiftool "-ThumbnailImage<=thumb.jpg" dst.jpg# write a tag to the XMP group (otherwise it would get written to the IPTC group since the City tag exists in both, and IPTC has priority):
exiftool -xmp:city=Kingston dst.jpg# delete LightSource tag only if it is unknown with a value of 0:
exiftool -LightSource-="Unknown (0)" dst.tiff# add DocumentName tag only if it didn't exist before
exiftool -DocumentName-= DocumentName='My Document' dst.jpg# set WhiteBalance to Tungsten only if it was previously Auto
exiftool -whitebalance-=auto -WhiteBalance=tung dst.jpg
# extract information from stdin:
cat a.jpg | exiftool -# add an IPTC keyword in a pipeline, saving output to a new file
cat a.jpg | exiftool -iptc:keywords+=fantastic - > b.jpg
produces output like this
# this is a comment line File $FileName was created on $DateTimeOriginal (f/$Aperture, $ShutterSpeed sec, ISO $EXIF:ISO)
File test.jpg was created on 2003:10:31 15:44:19 (f/5.6, 1/60 sec, ISO 100)
Note that some tag values may be returned as SCALAR references indicating binary data. The simple script above does not handle this case.
#!/usr/bin/perl -w use Image::ExifTool 'ImageInfo'; my $file = shift or die "Please specify filename"; my $info = ImageInfo($file); foreach (keys %$info) { print "$_ : $info->{$_}\n"; }
See the Image::ExifTool Documentation for more details.
ie) "exiftool -filename -imagesize -exif:fnumber image.jpg"
A complete list of ExifTool Tag Names accompanies this documentation. As well, current lists of available tag names and writable tag names may also be obtained using the exiftool -list and -listw options. But perhaps the easiest way to determine a tag name is to use the -S option to print the tag names instead of descriptions for all information in a file. It may also be useful to use the -G option to display the group names, and the -H or -D option to print the numerical tag ID's for reference.
Notes:
ExifTool writes five different types of meta information:
1) EXIF 2) GPS 3) IPTC 4) XMP 5) MakerNotesMany tag names are valid for more than one of these groups. If a specific group is not given then new information is added only to the highest priority group for which the tag name is valid (but the information is changed in all groups where the tag already existed). The priority of the groups is given by the list above. Information is added preferentially to the EXIF or GPS group (there are no common tag names between these two groups). If the tag isn't valid in either of these two groups, the information is added to the IPTC group, or finally the XMP group. The Makernotes group is special, see the note below.
Alternatively, information may be written to a specific group only, bypassing these priorities, by providing a group name for the tag. The section below gives the syntax rules for exiftool command-line arguments to do this.
Note: Information in the MakerNotes may be edited, but not added or deleted. The reason for this is to avoid confusing manufacturer-specific software which may be very inflexible about the information it expects in the maker notes. The exception is the JpgFromRaw image, which may be added or deleted from Canon CRW files. This has been tested and doesn't cause problems for me with the Canon software or Photoshop, however it does confuse Capture One somewhat if this image is missing, so beware.
Tag values are writen rather than being extracted if the tag name ends with a '=' symbol. The '=' may be prefixed by '+', '-' or '<' to add a value, remove a value or set a value from file. The following table outlines the different write syntaxes:
Syntax Result -TAG= Deletes all occurrances of TAG -GROUP:TAG= Deletes TAG only in specified group -[GROUP:]TAG=VALUE Sets value of TAG (only in GROUP if specified) -[GROUP:]TAG+=VALUE Adds value to a tag list (only valid for List type tags) -[GROUP:]TAG-=VALUE Deletes TAG only if it has the specified value -[GROUP:]TAG<=FILE Sets tag value from contents of specified file
Note that quotes are required around VALUE if it contains spaces, and around the whole argument if the '<=' syntax is used (to prevent shell redirection).