Image::ExifTool(3pm) | User Contributed Perl Documentation | Image::ExifTool(3pm) |
Image::ExifTool - Read and write meta information
use Image::ExifTool qw(:Public); # ---- Simple procedural usage ---- # Get hash of meta information tag names/values from an image $info = ImageInfo('a.jpg'); # ---- Object-oriented usage ---- # Create a new Image::ExifTool object $exifTool = new Image::ExifTool; # Extract meta information from an image $exifTool->ExtractInfo($file, \%options); # Get list of tags in the order they were found in the file @tagList = $exifTool->GetFoundTags('File'); # Get the value of a specified tag $value = $exifTool->GetValue($tag, $type); # Get a tag description $description = $exifTool->GetDescription($tag); # Get the group name associated with this tag $group = $exifTool->GetGroup($tag, $family); # Set a new value for a tag $exifTool->SetNewValue($tag, $newValue); # Write new meta information to a file $success = $exifTool->WriteInfo($srcfile, $dstfile); # ...plus a host of other useful methods...
Reads and writes meta information in a wide variety of files, including the maker notes of many digital cameras by various manufacturers such as Canon, Casio, DJI, FLIR, FujiFilm, GE, GoPro, HP, JVC/Victor, Kodak, Leaf, Minolta/Konica-Minolta, Nikon, Nintendo, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Phase One, Reconyx, Ricoh, Samsung, Sanyo, Sigma/Foveon and Sony.
Below is a list of file types and meta information formats currently supported by ExifTool (r = read, w = write, c = create):
File Types ------------+-------------+-------------+-------------+------------ 360 r/w | DPX r | ITC r | ODP r | RIFF r 3FR r | DR4 r/w/c | J2C r | ODS r | RSRC r 3G2 r/w | DSS r | JNG r/w | ODT r | RTF r 3GP r/w | DV r | JP2 r/w | OFR r | RW2 r/w A r | DVB r/w | JPEG r/w | OGG r | RWL r/w AA r | DVR-MS r | JSON r | OGV r | RWZ r AAE r | DYLIB r | K25 r | ONP r | RM r AAX r/w | EIP r | KDC r | OPUS r | SEQ r ACR r | EPS r/w | KEY r | ORF r/w | SKETCH r AFM r | EPUB r | LA r | OTF r | SO r AI r/w | ERF r/w | LFP r | PAC r | SR2 r/w AIFF r | EXE r | LNK r | PAGES r | SRF r APE r | EXIF r/w/c | LRV r/w | PBM r/w | SRW r/w ARQ r/w | EXR r | M2TS r | PCD r | SVG r ARW r/w | EXV r/w/c | M4A/V r/w | PCX r | SWF r ASF r | F4A/V r/w | MACOS r | PDB r | THM r/w AVI r | FFF r/w | MAX r | PDF r/w | TIFF r/w AVIF r/w | FITS r | MEF r/w | PEF r/w | TORRENT r AZW r | FLA r | MIE r/w/c | PFA r | TTC r BMP r | FLAC r | MIFF r | PFB r | TTF r BPG r | FLIF r/w | MKA r | PFM r | TXT r BTF r | FLV r | MKS r | PGF r | VCF r CHM r | FPF r | MKV r | PGM r/w | VRD r/w/c COS r | FPX r | MNG r/w | PLIST r | VSD r CR2 r/w | GIF r/w | MOBI r | PICT r | WAV r CR3 r/w | GPR r/w | MODD r | PMP r | WDP r/w CRM r/w | GZ r | MOI r | PNG r/w | WEBP r CRW r/w | HDP r/w | MOS r/w | PPM r/w | WEBM r CS1 r/w | HDR r | MOV r/w | PPT r | WMA r CSV r | HEIC r/w | MP3 r | PPTX r | WMV r CZI r | HEIF r/w | MP4 r/w | PS r/w | WTV r DCM r | HTML r | MPC r | PSB r/w | WV r DCP r/w | ICC r/w/c | MPG r | PSD r/w | X3F r/w DCR r | ICS r | MPO r/w | PSP r | XCF r DFONT r | IDML r | MQV r/w | QTIF r/w | XLS r DIVX r | IIQ r/w | MRW r/w | R3D r | XLSX r DJVU r | IND r/w | MXF r | RA r | XMP r/w/c DLL r | INSP r/w | NEF r/w | RAF r/w | ZIP r DNG r/w | INSV r | NRW r/w | RAM r | DOC r | INX r | NUMBERS r | RAR r | DOCX r | ISO r | O r | RAW r/w | Meta Information ----------------------+----------------------+--------------------- EXIF r/w/c | CIFF r/w | Ricoh RMETA r GPS r/w/c | AFCP r/w | Picture Info r IPTC r/w/c | Kodak Meta r/w | Adobe APP14 r XMP r/w/c | FotoStation r/w | MPF r MakerNotes r/w/c | PhotoMechanic r/w | Stim r Photoshop IRB r/w/c | JPEG 2000 r | DPX r ICC Profile r/w/c | DICOM r | APE r MIE r/w/c | Flash r | Vorbis r JFIF r/w/c | FlashPix r | SPIFF r Ducky APP12 r/w/c | QuickTime r | DjVu r PDF r/w/c | Matroska r | M2TS r PNG r/w/c | MXF r | PE/COFF r Canon VRD r/w/c | PrintIM r | AVCHD r Nikon Capture r/w/c | FLAC r | ZIP r GeoTIFF r/w/c | ID3 r | (and more)
User-defined tags can be added via the ExifTool configuration file, or by defining the %Image::ExifTool::UserDefined hash before calling any ExifTool methods. See "ExifTool_config" in the ExifTool distribution for more details.
By default ExifTool looks for a configuration file named ".ExifTool_config" first in your home directory, then in the directory of the application script, but a different directory may be specified by setting the EXIFTOOL_HOME environment variable, or a different file may be specified by setting the ExifTool "configFile" variable before using Image::ExifTool. For example:
BEGIN { $Image::ExifTool::configFile = '/Users/phil/myconfig.cfg' } use Image::ExifTool;
The configuration feature may also be disabled by setting "configFile" to an empty string:
BEGIN { $Image::ExifTool::configFile = '' } use Image::ExifTool;
Exports nothing by default, but "ImageInfo" and all static methods may be exported with the ":Public" export list.
All ExifTool features are accessed through the methods of the public interface listed below. Other Image::ExifTool methods and modules should not be accessed directly because their interface may change with future versions.
None of these methods should ever die or issue warnings to STDERR if called with the proper arguments (with the exception of "SetNewValue" which may send an error message to STDERR, but only when called in scalar context). Error and warning messages that occur during processing are stored in the values of the Error and Warning tags, and are accessible via the "GetValue" method to retrieve a single Error or Warning message, or "GetInfo" to retrieve any number of them.
The ExifTool methods are not thread safe.
Creates a new ExifTool object.
$exifTool = new Image::ExifTool;
Note that ExifTool uses AUTOLOAD to load non-member methods, so any class using Image::ExifTool as a base class must define an AUTOLOAD which calls Image::ExifTool::DoAutoLoad(). eg)
sub AUTOLOAD { Image::ExifTool::DoAutoLoad($AUTOLOAD, @_); }
Read image file and return meta information. This is the one step function for retrieving meta information from an image. Internally, "ImageInfo" calls "ExtractInfo" to extract the information, "GetInfo" to generate the information hash, and "GetTagList" for the returned tag list.
# return meta information for 2 tags only (procedural) $info = ImageInfo($filename, $tag1, $tag2); # return information about an open image file (object-oriented) $info = $exifTool->ImageInfo(\*FILE); # return information from image data in memory for specified tags %options = (PrintConv => 0); @tagList = qw(filename imagesize xmp:creator exif:* -ifd1:*); $info = ImageInfo(\$imageData, \@tagList, \%options); # extract information from an embedded thumbnail image $info = ImageInfo('image.jpg', 'thumbnailimage'); $thumbInfo = ImageInfo($$info{ThumbnailImage});
Below is an explanation of how the "ImageInfo" function arguments are interpreted:
Tag names are case-insensitive and may be prefixed by optional group names separated by colons. A group name may begin with a family number (eg. '1IPTC:Keywords'), to restrict matches to a specific family. In the tag name, a '?' matches any single character and a '*' matches zero or more characters. Thus 'GROUP:*' represents all tags in a specific group. Wildcards may not be used in group names, with the exception that a group name of '*' may be used to extract all available instances of a tag regardless of the "Duplicates" setting (eg. '*:WhiteBalance'). Multiple groups may be specified (eg. 'EXIF:Time:*' extracts all EXIF Time tags). And finally, a leading '-' indicates a tag to be excluded (eg. '-IFD1:*'), or a trailing '#' causes the ValueConv value to be returned for this tag.
Note that keys in the returned information hash and elements of the returned tag list are not necessarily the same as these tag names because group names are removed, the case may be changed, and an instance number may be added. For this reason it is best to use either the keys of the returned hash or the elements of the returned tag list when accessing the tag values.
See Image::ExifTool::TagNames for a complete list of ExifTool tag names.
[Advanced: To allow a non-rewindable stream (eg. a network socket) to be re-read after processing with ExifTool, first wrap the file reference in a File::RandomAccess object, then pass this object to "ImageInfo". The File::RandomAccess object will buffer the file if necessary, and may be used to re-read the file after "ImageInfo" returns.]
There will be 1:1 correspondence between the requested tags and the returned tag keys only if the "Duplicates" option is 0 and "Sort" is 'Input'. (With "Duplicates" enabled, there may be more entries in the returned list of tag keys, and with other "Sort" settings the entries may not be in the same order as requested.) If a requested tag doesn't exist, a tag key is still generated, but the tag value is undefined.
foreach (sort keys %$info) { print "$_ => $$info{$_}\n"; }
Values of the returned hash are usually simple scalars, but a scalar reference is used to indicate binary data and an array reference may be used to indicate a list. Also, a hash reference may be returned if the "Struct" option is used. Lists of values are joined by commas into a single string only if the PrintConv option is enabled and the ListJoin option is enabled (which are the defaults). Note that binary values are not necessarily extracted unless specifically requested, or the Binary option is enabled and the tag is not specifically excluded. If not extracted the value is a reference to a string of the form "Binary data ##### bytes".
The code below gives an example of how to handle these return values, as well as illustrating the use of other ExifTool functions:
use Image::ExifTool; my $exifTool = new Image::ExifTool; $exifTool->Options(Unknown => 1); my $info = $exifTool->ImageInfo('a.jpg'); my $group = ''; my $tag; foreach $tag ($exifTool->GetFoundTags('Group0')) { if ($group ne $exifTool->GetGroup($tag)) { $group = $exifTool->GetGroup($tag); print "---- $group ----\n"; } my $val = $info->{$tag}; if (ref $val eq 'SCALAR') { if ($$val =~ /^Binary data/) { $val = "($$val)"; } else { my $len = length($$val); $val = "(Binary data $len bytes)"; } } printf("%-32s : %s\n", $exifTool->GetDescription($tag), $val); }
As well as tags representing information extracted from the image, the following Extra tags generated by ExifTool may be returned:
ExifToolVersion - The ExifTool version number. Error - An error message if the image could not be processed. Warning - A warning message if problems were encountered while processing the image.
Get/set ExifTool options. This function can be called to set the default options for an ExifTool object. Options set this way are in effect for all function calls but may be overridden by options passed as arguments to some functions. Option names are not case sensitive.
The default option values may be changed by defining a %Image::ExifTool::UserDefined::Options hash. See the ExifTool_config file in the full ExifTool distribution for examples.
# exclude the 'OwnerName' tag from returned information $exifTool->Options(Exclude => 'OwnerName'); # only get information in EXIF or MakerNotes groups $exifTool->Options(Group0 => ['EXIF', 'MakerNotes']); # ignore information from IFD1 $exifTool->Options(Group1 => '-IFD1'); # sort by groups in family 2, and extract unknown tags $exifTool->Options(Sort => 'Group2', Unknown => 1); # reset DateFormat option $exifTool->Options(DateFormat => undef); # do not extract duplicate tag names $oldSetting = $exifTool->Options(Duplicates => 0); # get current Verbose setting $isVerbose = $exifTool->Options('Verbose'); # set a user parameter $exifTool->Options(UserParam => 'MyParam=some value');
1) Option parameter name (case-insensitive)
2) [optional] Option parameter value (may be undef to clear option)
3-N) [optional] Additional parameter/value pairs
Value Alias(es) Description ----------- --------------- ---------------------------------- UTF8 cp65001, UTF-8 UTF-8 characters Latin cp1252, Latin1 Windows Latin1 (West European) Latin2 cp1250 Windows Latin2 (Central European) Cyrillic cp1251, Russian Windows Cyrillic Greek cp1253 Windows Greek Turkish cp1254 Windows Turkish Hebrew cp1255 Windows Hebrew Arabic cp1256 Windows Arabic Baltic cp1257 Windows Baltic Vietnam cp1258 Windows Vietnamese Thai cp874 Windows Thai DOSLatinUS cp437 DOS Latin US DOSLatin1 cp850 DOS Latin1 DOSCyrillic cp866 DOS Cyrillic MacRoman cp10000, Roman Macintosh Roman MacLatin2 cp10029 Macintosh Latin2 (Central Europe) MacCyrillic cp10007 Macintosh Cyrillic MacGreek cp10006 Macintosh Greek MacTurkish cp10081 Macintosh Turkish MacRomanian cp10010 Macintosh Romanian MacIceland cp10079 Macintosh Icelandic MacCroatian cp10082 Macintosh Croatian
Note that this option affects some types of information when reading/writing the file and other types when getting/setting tag values, so it must be defined for both types of access. See the "CHARACTER ENCODINGS" section for more information about the handling of special characters.
Note that this option affects some types of information when reading/writing the file and other types when getting/setting tag values, so it must be defined for both types of access.
NoPadding - Avoid 2 kB of recommended padding at end of XMP (NoPad) NoIndent - No spaces to indent lines (NoSpace, NoSpaces) NoNewline - Avoid unnecessary newlines (NoNewlines) Shorthand - Use XMP Shorthand format OneDesc - Combine properties into a single rdf:Description (OneDescr) AllSpace - Equivalent to 'NoPadding,NoIndent,NoNewline' AllFormat - Equivalent to 'Shorthand,OneDesc' All - Equivalent to 'AllSpace,AllFormat'
CoordFormat Example Output ------------------- ------------------ q{%d deg %d' %.2f"} 54 deg 59' 22.80" (default for reading) q{%d %d %.8f} 54 59 22.80000000 (default for copying) q{%d deg %.4f min} 54 deg 59.3800 min q{%.6f degrees} 54.989667 degrees
Note: To avoid loss of precision, the default coordinate format is different when copying tags with "SetNewValuesFromFile".
0 - Ignore all extended XMP 1 - Read extended XMP with valid GUID only (default) 2 - Read extended XMP with any GUID <guid> - Read extended XMP with a specific GUID
'K', 'k' or 'km/h' - km/h 'M', 'm' or 'mph' - mph <anything else> - knots (default undef)
0 - Do not extract writable subdirectories (same as default of undef) 1 - Extract and rebuild maker notes into self-contained block 2 - Extract without rebuilding maker notes
Input - Sort in same order as input tag arguments (default) File - Sort in order that tags were found in the file Tag - Sort alphabetically by tag name Descr - Sort by tag description (for current Lang setting) Group# - Sort by tag group, where # is zero or more family numbers separated by colons. If # is not specified, Group0 is assumed. See GetGroup for a description of group families.
File - Sort in order tags were found in the file (default) Tag - Sort alphabetically by tag name Descr - Sort by tag description (for current Lang setting)
undef - Same as 0 for reading/writing, or 1 for copying 0 - Return date/time value unchanged if it can't be converted 1 - Return undef if date/time value can't be converted
When set to 1 while writing a PrintConv date/time value with the DateFormat option set, the value is written only if POSIX::strptime or Time::Piece is available and can successfully convert the value.
For PNG CreationTime, a setting of 1 has the additional effect of causing the date/time to be reformatted according to PNG 1.2 recommendation (RFC-1123) when writing, and a warning to be issued for any non-standard value when reading (but note that Windows may not recognize PNG date/time values in standard format).
undef - (default) Same as 0 for reading, 2 for copying 0 - Read/copy flattened tags 1 - Read/copy structured tags 2 - Read/copy both flattened and structured tags, but flag flattened tags as 'unsafe' for copying
PARAM - Get parameter PARAM= - Clear parameter PARAM^= - Set parameter to empty string PARAM=VALUE - Set parameter <hash ref> - Set entire UserParam hash lookup undef - Clear all user parameters
Where PARAM is the user-defined parameter name (case insensitive).
User-defined parameters may be accessed in tag name expressions by prefixing the parameter name with a dollar sign just like normal tags, or via the API by calling "Options('UserParam','PARAM')". Appending a hash tag ("#") to the parameter name also causes the parameter to be extracted as a normal tag (in the UserParam group). If called without additional arguments, "Options('UserParam')" returns a reference to the hash of all user parameters (with lower-case names).
w - Write existing tags c - Create new tags g - create new Groups as necessary
The level of the group differs for different types of metadata. For XMP or IPTC this is the full XMP/IPTC block (the family 0 group), but for EXIF this is the individual IFD (the family 1 group). The 'w' and 'c' modes are tested only when "SetNewValue" is called, but the 'g' mode is also tested in "WriteInfo".
Reset all options to their default values. Loads user-defined default option values from the %Image::ExifTool::UserDefined::Options hash in the .ExifTool_config file if it exists.
$exifTool->ClearOptions();
Extract all meta information from an image.
$success = $exifTool->ExtractInfo('image.jpg', \%options);
Binary, Charset, CharsetEXIF, CharsetFileName, CharsetID3, CharsetIPTC, CharsetPhotoshop, CharsetQuickTime, CharsetRIFF, Composite, ExtendedXMP, ExtractEmbedded, FastScan, FixBase, HtmlDump, HtmlDumpBase, IgnoreMinorErrors, Lang, LargeFileSupport, MakerNotes, MDItemTags, NoPDFList, Password, QuickTimeUTC (enforced 1904 time zero), RequestAll, RequestTags, SaveFormat, SavePath, ScanForXMP, Struct, TextOut, Unknown, Verbose, XAttrTags and XMPAutoConv.
"GetInfo" is called to return meta information after it has been extracted from the image by a previous call to "ExtractInfo" or "ImageInfo". This function may be called repeatedly after a single call to "ExtractInfo" or "ImageInfo".
# get image width and height only $info = $exifTool->GetInfo('ImageWidth', 'ImageHeight'); # get all Error and Warning messages $info = $exifTool->GetInfo('Error', 'Warning'); # get information for all tags in list (list updated with tags found) $info = $exifTool->GetInfo(\@ioTagList); # get all information in Author or Location groups $info = $exifTool->GetInfo({Group2 => ['Author', 'Location']});
Charset, CoordFormat, DateFormat, Duplicates, Escape, Exclude, Filter, Group#, GlobalTimeShift, Lang, ListItem, ListJoin, PrintConv, Sort (if a tag list reference is given) and StrictDate.
The following options are effective in the call to "GetInfo":
Charset, CoordFormat, DateFormat, Duplicates, Escape, Exclude, Filter, Group#, GlobalTimeShift, Lang, ListItem, ListJoin, PrintConv, QuickTimeUTC (conversion to local time), Sort (if a tag list reference is given) and StrictDate.
Write meta information to a file. The specified source file is rewritten to the same-type destination file with new information as specified by previous calls to "SetNewValue". The necessary segments and/or directories are created in the destination file as required to store the specified information. May be called repeatedly to write the same information to additional files without the need to call "SetNewValue" again.
ExifTool queues all new values that are assigned via calls to "SetNewValue", then applies them to any number of files through one or more calls to "WriteInfo". These queued values may be accessed through "GetNewValue", and are completely separate from metadata extracted from files via "ExtractInfo" or "ImageInfo" and accessed through "GetInfo" or "GetValue".
To be clear, it is NOT necessary to call "ExtractInfo" or "ImageInfo" before "WriteInfo". "WriteInfo" changes only metadata specified by previous calls to "SetNewValue".
# add information to a source file, writing output to new file $exifTool->WriteInfo($srcfile, $dstfile); # create XMP data file from scratch $exifTool->WriteInfo(undef, $dstfile, 'XMP'); # overwrite file (you do have backups, right?) $exifTool->WriteInfo($srcfile);
1) Source file name, file reference, scalar reference, or undef to create a file from scratch. A reference to a File::RandomAccess object is also allowed as a source, but in this case the destination is not optional.
2) [optional] Destination file name, file reference, scalar reference, or undef to overwrite the original file. May be '-' to write to stdout.
3) [optional] Destination file type. Ignored if a source is defined.
If an error code is returned, an Error tag is set and GetValue('Error') can be called to obtain the error description. A Warning tag may be set even if this routine is successful. Calling WriteInfo clears any pre-existing Error and Warning tags.
$errorMessage = $exifTool->GetValue('Error'); $warningMessage = $exifTool->GetValue('Warning');
If a destination file name is given, the specified file must not exist because an existing destination file will not be overwritten. Any new values for FileName, Directory or HardLink are ignored when a destination file name is specified.
The destination file name may be undefined to overwrite the original file (make sure you have backups!). In this case, if a source file name is provided, a temporary file is created and renamed to replace the source file if no errors occurred while writing. Otherwise, if a source file reference or scalar reference is used, the image is first written to memory then copied back to replace the original if there were no errors.
On Mac OS systems, the file resource fork is preserved if this routine is called with a source file name.
The following ExifTool options are effective in the call to "WriteInfo":
ByteOrder, Charset, CharsetEXIF, CharsetFileName, CharsetIPTC, Compact, Compress, FixBase, IgnoreMinorErrors, Password, QuickTimeHandler, Verbose and WriteMode.
Get a sorted list of tags from the specified information hash or tag list.
@tags = $exifTool->GetTagList($info, 'Group0');
1) [optional] Information hash reference or tag list reference
2) [optional] Sort order ('Input', 'File', 'Tag', 'Descr' or 'Group#')
3) [optional] Secondary sort order ('File', 'Tag' or 'Descr')
If the information hash or tag list reference is not provided, then the list of found tags from the last call to "ImageInfo", "ExtractInfo" or "GetInfo" is used instead, and the result is the same as if "GetFoundTags" was called. If sort order is not specified, the sort order is taken from the current options settings.
Get list of found tags in specified sort order. The found tags are the tags for the information obtained from the most recent call to "ImageInfo", "ExtractInfo" or "GetInfo" for this object.
@tags = $exifTool->GetFoundTags('File');
1) [optional] Sort order ('Input', 'File', 'Tag', 'Descr' or 'Group#')
2) [optional] Secondary sort order ('File', 'Tag' or 'Descr')
If sort order is not specified, the sort order from the ExifTool options is used.
Get list of requested tags. These are the tags that were specified in the arguments of the most recent call to "ImageInfo", "ExtractInfo" or "GetInfo", including tags specified via a tag list reference. Shortcut tags are expanded in the list.
@tags = $exifTool->GetRequestedTags();
Get the value of a specified tag. The returned value is either the human-readable (PrintConv) value, the converted machine-readable (ValueConv) value, the original raw (Raw) value, or the original rational (Rational) value for rational formats. If the value type is not specified, the PrintConv value is returned if the PrintConv option is set, otherwise the ValueConv value is returned. The PrintConv values are same as the values returned by "ImageInfo" and "GetInfo" in the tag/value hash unless the PrintConv option is disabled.
Tags which represent lists of multiple values (as may happen with 'Keywords' for example) are handled specially. In scalar context, the returned PrintConv value for these tags is either a string of values or a list reference (depending on the ListJoin option setting), and the ValueConv value is always a list reference. But in list context, "GetValue" always returns the list itself.
Note that "GetValue" requires a case-sensitive tag key as an argument. To retrieve tag information based on a case-insensitive tag name (with an optional group specifier), use "GetInfo" instead.
# PrintConv example my $val = $exifTool->GetValue($tag); if (ref $val eq 'SCALAR') { print "$tag = (unprintable value)\n"; } else { print "$tag = $val\n"; } # ValueConv examples my $val = $exifTool->GetValue($tag, 'ValueConv'); if (ref $val eq 'ARRAY') { print "$tag is a list of values\n"; } elsif (ref $val eq 'SCALAR') { print "$tag represents binary data\n"; } else { print "$tag is a simple scalar\n"; } my @keywords = $exifTool->GetValue('Keywords', 'ValueConv');
The following options are in effect when "GetValue" is called:
Charset, CoordFormat, DateFormat, Escape, Filter, GlobalTimeShift, Lang, ListItem, ListJoin, PrintConv, QuickTimeUTC (conversion to local time), StrictDate and TimeZone.
1) Tag key, or case-sensitive tag name with optional group prefix(es)
2) [optional] Value type: 'PrintConv', 'ValueConv', 'Both', 'Raw' or 'Rational'
The default value type is 'PrintConv' if the PrintConv option is set, otherwise the default is 'ValueConv'. A value type of 'Both' returns both ValueConv and PrintConv values as a list. 'Rational' returns the raw rational value as a string fraction for rational types, or undef for other types.
Note: It is possible for "GetValue" to return an undefined ValueConv or PrintConv value (or an empty list in list context) even if the tag exists, since it is possible for these conversions to yield undefined values. And the Rational value will be undefined for any non-rational tag. The Raw value should always exist if the tag exists.
Set the new value for a tag. The routine may be called multiple times to set the values of many tags before using "WriteInfo" to write the new values to an image.
For list-type tags (like Keywords), either call repeatedly with the same tag name for each value, or call with a reference to the list of values.
# set a new value for a tag (errors go to STDERR) $success = $exifTool->SetNewValue($tag, $value); # set a new value and capture any error message ($success, $errStr) = $exifTool->SetNewValue($tag, $value); # delete information for specified tag if it exists in image # (also resets AddValue and DelValue options for this tag) $exifTool->SetNewValue($tag); # reset all values from previous calls to SetNewValue() $exifTool->SetNewValue(); # delete a specific keyword $exifTool->SetNewValue('Keywords', $word, DelValue => 1); # set keywords (a list-type tag) with two new values $exifTool->SetNewValue(Keywords => 'word1'); $exifTool->SetNewValue(Keywords => 'word2'); # equivalent, but set both in one call using an array reference $exifTool->SetNewValue(Keywords => ['word1','word2']); # add a keyword without replacing existing keywords in the file $exifTool->SetNewValue(Keywords => $word, AddValue => 1); # conditionally add a tag if it didn't exist before, # or replace it if it had a specified value ("old value") $exifTool->SetNewValue(Description => '', DelValue => 1); $exifTool->SetNewValue(Description => 'old value', DelValue => 1); $exifTool->SetNewValue(Description => 'new value'); # set a tag in a specific group $exifTool->SetNewValue(Headline => $val, Group => 'XMP'); $exifTool->SetNewValue('XMP:Headline' => $val); # (equivalent) # shift original date/time back by 2.5 hours $exifTool->SetNewValue(DateTimeOriginal => '2:30', Shift => -1); # write a tag only if it had a specific value # (the order of the following calls is not significant) $exifTool->SetNewValue(Title => $oldVal, DelValue => 1); $exifTool->SetNewValue(Title => $newVal); # write tag by numerical value $exifTool->SetNewValue(Orientation => 6, Type => 'ValueConv'); $exifTool->SetNewValue('Orientation#' => 6); # (equivalent) # delete all but EXIF tags $exifTool->SetNewValue('*'); # delete all... $exifTool->SetNewValue('EXIF:*', undef, Replace => 2); # ...but EXIF # write structured information as a HASH reference $exifTool->SetNewValue('XMP:Flash' => { mode => 'on', fired => 'true', return => 'not' }); # write structured information as a serialized string $exifTool->SetNewValue('XMP:Flash'=>'{mode=on,fired=true,return=not}');
(See <https://exiftool.org/struct.html#Serialize> for a description of the structure serialization technique.)
1) [optional] Tag key or tag name, or undef to clear all new values. The tag name may be prefixed by one or more family 0, 1 or 2 group names with optional leading family numbers, separated by colons (eg. 'EXIF:Artist', 'XMP:Time:*'), which is equivalent to using a Group option argument. Also, a '#' may be appended to the tag name (eg. 'EXIF:Orientation#'), with the same effect as setting Type to 'ValueConv'. Wildcards ('*' and '?') may be used in the tag name to assign multiple tags simultaneously. A tag name of '*' is special when deleting information, and will delete an entire group even if some individual tags in the group are not writable, but only if a single family 0 or 1 group is specified (otherwise the tags are deleted individually). Use "GetDeleteGroups" to get a list of deletable group names, and see Image::ExifTool::TagNames for a complete list of tag names.
2) [optional] New value for tag. Undefined to delete tag from file. May be a scalar, scalar reference, list reference to set a list of values, or hash reference for a structure. Integer values may be specified as a hexadecimal string (with a leading '0x'), and simple rational values may be specified in fractional form (eg. '4/10'). Structure tags may be specified either as a hash reference or a serialized string (see the last two examples above).
3-N) [optional] SetNewValue option/value pairs (see below).
When deleting all tags from a JPEG image, the APP14 "Adobe" information is not deleted by default because doing so may affect the appearance of the image. However, this information may be deleted by specifying it explicitly, either by group (with 'Adobe:*') or as a block (with 'Adobe').
The following ExifTool options are effective in the call to "SetNewValue":
Charset, DateFormat, Escape, IgnoreMinorErrors, Lang, ListJoin, ListSplit, PrintConv, QuickTimeUTC, StrictDate, TimeZone, Verbose and WriteMode.
Get the new Raw value for a tag. This is the value set by "SetNewValue" this is queued to be written to file. List-type tags may return multiple values in list context.
$rawVal = $exifTool->GetNewValue($tag); @rawVals = $exifTool->GetNewValue($tag);
1) Tag name (case sensitive, may be prefixed by family 0, 1 or 7 group names, separated by colons)
A very powerful routine that sets new values for tags from information found in a specified file.
# set new values from all information in a file... my $info = $exifTool->SetNewValuesFromFile($srcFile); # ...then write these values to another image my $result = $exifTool->WriteInfo($file2, $outFile); # set all new values, preserving original groups $exifTool->SetNewValuesFromFile($srcFile, '*:*'); # set specific information $exifTool->SetNewValuesFromFile($srcFile, @tags); # set new value from a different tag in specific group $exifTool->SetNewValuesFromFile($fp, 'XMP-dc:Subject<IPTC:Keywords'); # add all IPTC keywords to XMP subject list $exifTool->SetNewValuesFromFile($fp, 'XMP-dc:Subject+<IPTC:Keywords'); # set new value from an expression involving other tags $exifTool->SetNewValuesFromFile($file, 'Comment<ISO=$ISO Aperture=$aperture Exposure=$shutterSpeed'); # set keywords list from the values of multiple tags $exifTool->SetNewValuesFromFile($file, { Replace => 0 }, 'keywords<xmp:subject', 'keywords<filename'); # copy all EXIF information, preserving the original IFD # (without '*.*<' tags would be copied to the preferred EXIF IFD) $exifTool->SetNewValuesFromFile($file, '*:*<EXIF:*'); # copy all tags with names starting with "gps" (note: this is # different than "gps:*" because it will also copy XMP GPS tags) $exifTool->SetNewValuesFromFile($file, 'gps*'); # set FileName from Model, translating questionable characters $exifTool->SetNewValuesFromFile($file, 'filename<${model; tr(/\\\\?*:|"><)(_) }.jpg');
1) File name, file reference, or scalar reference
2-N) [optional] List of tag names to set or options hash references. All writable tags are set if none are specified. The tag names are not case sensitive, and may be prefixed by one or more family 0, 1, 2 or 7 group names with optional leading family numbers, separated by colons (eg. 'exif:iso'). A leading '-' indicates tags to be excluded (eg. '-comment'), or a trailing '#' causes the ValueConv value to be copied (same as setting the Type option to 'ValueConv' for this tag only). Wildcards ('*' and '?') may be used in the tag name. A tag name of '*' is commonly used when a group is specified to copy all tags in the group (eg. 'XMP:*'). A special feature allows tag names of the form 'DSTTAG<SRCTAG' (or 'SRCTAG>DSTTAG') to be specified to copy information to a tag with a different name or a specified group. Both 'SRCTAG' and 'DSTTAG' may contain wildcards and/or be prefixed by a group name (eg. 'fileModifyDate<modifyDate' or 'xmp:*<*'), and/or suffixed by a '#' to disable print conversion. Copied tags may also be added or deleted from a list with arguments of the form 'DSTTAG+<SRCTAG' or 'DSTTAG-<SRCTAG'. Tags are evaluated in order, so exclusions apply only to tags included earlier in the list. An extension of this feature allows the tag value to be set from a string containing tag names with leading '$' symbols (eg. 'Comment<the file is $filename'). Braces '{}' may be used around the tag name to separate it from subsequent text, and a '$$' is used to to represent a '$' symbol. The behaviour for missing tags in expressions is defined by the "MissingTagValue" option. The tag value may be modified via changes to the default input variable ($_) in a Perl expression placed inside the braces and after a semicolon following the tag name (see the last example above). A '@' may be added after the tag name (before the semicolon) to make the expression act on individual list items instead of the concatenated string for list-type tags. Braces within the expression must be balanced. Multiple options hash references may be passed to set different options for different tags. Options apply to subsequent tags in the argument list.
By default, this routine will commute information between same-named tags in different groups, allowing information to be translated between images with different formats. This behaviour may be modified by specifying a group name for extracted tags (even if '*' is used as a group name), in which case the information is written to the original group, unless redirected to a different group. When '*' is used for a group name, by default the family 1 group of the original tag is preserved, but a different family may be specified with a leading family number. (For example, specifying '*:*' copies all information while preserving the original family 1 groups, while '0*:*' preserves the family 0 group.)
- The Replace option defaults to 1 instead of 0 as with "SetNewValue".
- The AddValue or DelValue option is set for individual tags if '+>' or '->' (or '+<' or '-<') are used.
- The Group option is set for tags where a group name is given.
- The Protected flag is set to 1 for individually specified tags.
- The Type option also applies to extracted tags.
If a preview image exists, it is not copied. The preview image must be transferred separately if desired, in a separate call to "WriteInfo"
When simply copying all information between files of the same type, it is usually desirable to preserve the original groups by specifying '*:*' for the tags to set.
The "Duplicates" option is always in effect for tags extracted from the source file using this routine.
The "Struct" option is enabled by default for tags extracted by this routine. This allows the hierarchy of complex structures to be preserved when copying, but the Struct option may be set to 0 to override this behaviour and copy as flattened tags instead.
Return the total number of new values set.
$numSet = $exifTool->CountNewValues(); ($numSet, $numPseudo) = $exifTool->CountNewValues();
Save state of new values to be later restored by "RestoreNewValues".
$exifTool->SaveNewValues(); # save state of new values $exifTool->SetNewValue(ISO => 100); # set new value for ISO $exifTool->WriteInfo($src, $dst1); # write ISO + previous new values $exifTool->RestoreNewValues(); # restore previous new values $exifTool->WriteInfo($src, $dst2); # write previous new values only
Restore new values to the settings that existed when "SaveNewValues" was last called. May be called repeatedly after a single call to "SaveNewValues". See "SaveNewValues" above for an example.
Write the filesystem modification or creation time from the new value of the FileModifyDate or FileCreateDate tag.
$exifTool->SetNewValue(FileModifyDate => '2000:01:02 03:04:05-05:00', Protected => 1); $result = $exifTool->SetFileModifyDate($file);
1) File name
2) [optional] Base time if applying shift (days before $^T)
3) [optional] Tag to write: 'FileModifyDate' (default), or 'FileCreateDate'
The ability to write FileCreateDate is currently restricted to Windows systems only.
Set the file name and directory, or create a hard link. If not specified, the new file name is derived from the new values of the FileName and Directory tags, or from the HardLink or SymLink tag if creating a link. If the FileName tag contains a '/', then the file is renamed into a new directory. If FileName ends with '/', then it is taken as a directory name and the file is moved into the new directory. The new value for the Directory tag takes precedence over any directory specified in FileName.
$result = $exifTool->SetFileName($file); $result = $exifTool->SetFileName($file, $newName);
1) Current file name
2) [optional] New file name
3) [optional] 'HardLink' or 'SymLink' to create a hard or symbolic link instead of renaming the file, or 'Test' to test renaming feature by printing the old and new names instead of changing anything.
Set the order of the preferred groups when adding new information. In subsequent calls to "SetNewValue", new information will be created in the first valid group of this list. This has an impact only if the group is not specified when calling "SetNewValue" and if the tag name exists in more than one group. The default order is EXIF, IPTC, XMP, MakerNotes, QuickTime, Photoshop, ICC_Profile, CanonVRD, Adobe. Any family 0 group name may be used. Case is not significant.
$exifTool->SetNewGroups('XMP','EXIF','IPTC');
1-N) Groups in order of priority. If no groups are specified, the priorities are reset to the defaults.
Get current group priority list.
@groups = $exifTool->GetNewGroups();
Get the ID for the specified tag. The ID is the IFD tag number in EXIF information, the property name in XMP information, or the data offset in a binary data block. For some tags, such as Composite tags where there is no ID, an empty string is returned. In list context, also returns a language code for the tag if available and different from the default language (eg. with alternate language entries for XMP "lang-alt" tags).
$id = $exifTool->GetTagID($tag); ($id, $lang) = $exifTool->GetTagID($tag);
1) Tag key
Get description for specified tag. This function will always return a defined value. In the case where the description doesn't exist, one is generated from the tag name.
1) Tag key
Get group name(s) for a specified tag.
# return family 0 group name (eg. 'EXIF'); $group = $exifTool->GetGroup($tag, 0); # return all groups (eg. qw{EXIF IFD0 Author Main}) @groups = $exifTool->GetGroup($tag); # return groups as a string (eg. 'Main:IFD0:Author') $group = $exifTool->GetGroup($tag, ':3:1:2'); # return groups as a simplified string (eg. 'IFD0:Author') $group = $exifTool->GetGroup($tag, '3:1:2');
1) Tag key
2) [optional] Group family number, or string of numbers separated by colons
0) Information Type (eg. EXIF, XMP, IPTC) 1) Specific Location (eg. IFD0, XMP-dc) 2) Category (eg. Author, Time) 3) Document Number (eg. Main, Doc1, Doc3-2) 4) Instance Number (eg. Copy1, Copy2, Copy3...) 5) Metadata Path (eg. JPEG-APP1-IFD0-ExifIFD) 6) EXIF/TIFF Format (eg. int8u, int32u, undef, string)
Families 0 and 1 are based on the file structure, and are similar except that family 1 is more specific and sub-divides some groups to give more detail about the specific location where the information was found. For example, the EXIF group is split up based on the specific IFD (Image File Directory), the MakerNotes group is divided into groups for each manufacturer, and the XMP group is separated based on the XMP namespace prefix. Note that only common XMP namespaces are listed in the GetAllGroups documentation, but additional namespaces may be present in some XMP data. Also note that the 'XMP-xmp...' group names may appear in the older form 'XMP-xap...' since these names evolved as the XMP standard was developed. The ICC_Profile group is broken down to give information about the specific ICC_Profile tag from which multiple values were extracted. As well, information extracted from the ICC_Profile header is separated into the ICC-header group.
Family 2 classifies information based on the logical category to which the information refers.
Family 3 gives the document number for tags extracted from embedded documents, or 'Main' for tags from the main document. (See the "ExtractEmbedded" option for extracting tags from embedded documents.) Nested sub-documents (if they exist) are indicated by numbers separated with dashes in the group name, to an arbitrary depth. (eg. 'Doc2-3-1' is the 1st sub-sub-document of the 3rd sub-document of the 2nd embedded document of the main file.) Document numbers are also used to differentiate samples for timed metadata in videos.
Family 4 provides a method for differentiating tags when multiple tags exist with the same name in the same location. The primary instance of a tag (the tag extracted when the Duplicates option is disabled and no group is specified) has no family 4 group name, but additional instances have family 4 group names of 'Copy1', 'Copy2', 'Copy3', etc. For convenience, the primary tag may also be accessed using a group name of 'Copy0'.
Family 5 is experimental, and gives the complete path for the metadata in the file. Generated only if the "SavePath" option is used when extracting.
Family 6 is currently used only for EXIF/TIFF metadata, and gives the format type of the extracted value. Generated only if the "SaveFormat" option is used when extracting.
Family 7 is used for tag ID's. The group names are "ID-" followed by the tag ID with characters other than [-_A-Za-z0-9] converted to hex. Numerical tag ID's are given in hex if the "HexTagIDs" option is set. When specifying a family 7 group name, numerical ID's may be in hex or decimal, and non-numercal ID's may or may not have characters other than [-_A-Za-z0-9] converted to hex. Note that unlike other group names, family 7 group names are case sensitive (except for the leading "ID-").
See "GetAllGroups [static]" for complete lists of group names.
Get list of group names that exist in the specified information.
@groups = $exifTool->GetGroups($info, 2); @groups = $exifTool->GetGroups('3:1');
1) [optional] Info hash ref (default is all extracted info)
2) [optional] Group family number, or string of numbers (default 0)
Builds composite tags from required tags. The composite tags are convenience tags which are derived from the values of other tags. This routine is called automatically by "ImageInfo" and "ExtractInfo" if the Composite option is set.
Composite tags may need to read data from the image for their value to be determined, and for these "BuildCompositeTags" must be called while the image is available. This is only a problem if "ImageInfo" is called with a filename (as opposed to a file reference or scalar reference) since in this case the file is closed before "ImageInfo" returns. Here the Composite option may be used so that "BuildCompositeTags" is called from within "ImageInfo", before the file is closed.
Get name of tag from tag key. This is a convenience function that strips the embedded instance number, if it exists, from the tag key.
Note: "static" in the heading above indicates that the function does not require an ExifTool object reference as the first argument. All functions documented below are also static.
$tagName = Image::ExifTool::GetTagName($tag);
Get a list of shortcut tags.
Get list of all available tag names.
@tagList = Image::ExifTool::GetAllTags($group);
Get list of all writable tag names.
@tagList = Image::ExifTool::GetWritableTags($group);
Get list of all group names in specified family.
@groupList = Image::ExifTool::GetAllGroups($family);
Here is a complete list of groups for each of these families:
Get list of all deletable group names.
@delGroups = Image::ExifTool::GetDeleteGroups();
AFCP, APP0, APP1, APP10, APP11, APP12, APP13, APP14, APP15, APP2, APP3, APP4, APP5, APP6, APP7, APP8, APP9, Adobe, Audio, Author, CIFF, Camera, CanonVRD, Document, Ducky, EXIF, ExifIFD, ExifTool, File, FlashPix, FotoStation, GPS, GlobParamIFD, ICC_Profile, IFD0, IFD1, IPTC, Image, InteropIFD, JFIF, Jpeg2000, Location, MIE, MPF, MakerNotes, Meta, MetaIFD, NikonCapture, Other, PDF, PDF-update, PNG, PNG-pHYs, PhotoMechanic, Photoshop, Preview, PrintIM, Printing, RMETA, RSRC, SubIFD, Time, Trailer, Video, XML, XML-*, XMP, XMP-*
To schedule a group for deletion, call "SetNewValue" with a tag name like 'EXIF:*' and an undefined tag value.
Deleting a family 0 or 1 group will delete the entire corresponding block of metadata, but deleting a family 2 group (eg. Audio, Author, Camera, etc.) deletes the individual tags belonging to that category.
The 'Trailer' group allows all trailers in JPEG and TIFF-format images to be deleted at once, including unknown trailers. Note that the JPEG "APP" groups are special, and are used only to delete application segments which are not associated with another deletable group. For example, deleting 'APP14:*' will delete other APP14 segments, but not the APP14 "Adobe" segment.
Get type of file given file name.
my $type = Image::ExifTool::GetFileType($filename); my $desc = Image::ExifTool::GetFileType($filename, 1);
1) [optional] Flag to return a description instead of a type. Default is undef. Set to 0 to also return types of recognized but unsupported files (otherwise the return value for unsupported files is undef), or 1 to return descriptions.
Can the specified file be written?
my $writable = Image::ExifTool::CanWrite($filename);
Can the specified file be created?
my $creatable = Image::ExifTool::CanCreate($filename);
Add user-defined tags to an existing tag table at run time. This differs from the usual technique of creating user-defined tags via the %Image::ExifTool::UserDefined hash (see the ExifTool_config file in the Image::ExifTool distribution) because it allows tags to be added after a tag table has been initialized.
use Image::ExifTool ':Public'; my %tags = ( TestTagID1 => { Name => 'TestTagName1' }, TestTagID2 => { Name => 'TestTagName2' }, ); my $num = AddUserDefinedTags('Image::ExifTool::PDF::Info', %tags);
1-N) Pairs of tag ID / tag information hash references for the new tags
Certain meta information formats allow coded character sets other than plain ASCII. When reading, most known encodings are converted to the external character set according to the "Charset" option, or to UTF-8 by default. When writing, the inverse conversions are performed. Alternatively, special characters may be converted to/from HTML character entities with the "Escape" HTML option.
A distinction is made between the external character set visible via the ExifTool API, and the internal character used to store text in the metadata of a file. These character sets may be specified separately as follows:
The encoding of file names is specified via the "CharsetFileName" option. By default, "CharsetFileName" is not defined, and file names passed to ExifTool are used directly in calls to the system i/o routines (which expect UTF-8 strings on Mac/Linux, but default to the system code page on Windows). In this mode on Windows a warning is issued if a file name contains special characters, but this warning may be avoided by setting "CharsetFileName" to an empty string. Setting "CharsetFileName" to any other value causes file names to be converted from the specified encoding to one appropriate for the system. In Windows this also has the effect of activating Unicode filename support via the special Windows wide-character i/o routines if Win32API::File is available.
Values are returned as byte strings of encoded characters. Perl wide characters are not used. By default, most returned strings are encoded in UTF-8. For these, Encode::decode_utf8() may be used to convert to a sequence of logical Perl characters. Note that some settings of the PERL_UNICODE environment variable may be incompatible with ExifTool's character handling.
More specific details are given below about how character coding is handled for EXIF, IPTC, XMP, PNG, ID3, PDF, Photoshop, QuickTime, AIFF, MIE and Vorbis information:
Most textual information in EXIF is stored in ASCII format (called "string" in the ExifTool tag name documentation). By default ExifTool does not convert these strings. However, it is not uncommon for applications to write UTF-8 or other encodings where ASCII is expected. To deal with these, ExifTool allows the internal EXIF string encoding to be specified with "CharsetEXIF", which causes EXIF string values to be converted from the specified character set when reading, and stored with this character set when writing. (The MWG recommends using UTF-8 encoding for EXIF strings, and in keeping with this the MWG module sets the default internal EXIF string encoding to UTF-8, but note that this will have no effect unless the external encoding is also set to something other than the default of UTF-8.)
A few EXIF tags (UserComment, GPSProcessingMethod and GPSAreaInformation) support a designated internal text encoding, with values stored as ASCII, Unicode (UCS-2) or JIS. When reading these tags, ExifTool converts Unicode and JIS to the external character set specified by the "Charset" option, or to UTF-8 by default. ASCII text is not converted. When writing, text is stored as ASCII unless the string contains special characters, in which case it is converted from the external character set (UTF-8 by default), and stored as Unicode. ExifTool writes Unicode in native EXIF byte ordering by default, but the byte order may be specified by setting the ExifUnicodeByteOrder tag (see the Extra Tags documentation).
The EXIF "XP" tags (XPTitle, XPComment, etc) are always stored as little-endian Unicode (UCS-2), and are read and written using the specified character set.
The value of the IPTC:CodedCharacterSet tag determines how the internal IPTC string values are interpreted. If CodedCharacterSet exists and has a value of 'UTF8' (or 'ESC % G') then string values are assumed to be stored as UTF-8, otherwise Windows Latin1 (cp1252, 'Latin') coding is assumed by default, but this can be changed with the "CharsetIPTC" option. When reading, these strings are converted to the character set specified by the "Charset" option. When writing, the inverse conversions are performed. No conversion is done if the internal (IPTC) and external (ExifTool) character sets are the same. Note that ISO 2022 character set shifting is not supported. Instead, a warning is issued and the string is not converted if an ISO 2022 shift code is encountered. See <http://www.iptc.org/IIM/> for the official IPTC specification.
ExifTool may be used to convert IPTC values to a different internal encoding. To do this, all IPTC tags must be rewritten along with the desired value of CodedCharacterSet. For example, the following command changes the internal IPTC encoding to UTF-8 (from Windows Latin1 unless CodedCharacterSet was already 'UTF8'):
exiftool -tagsfromfile @ -iptc:all -codedcharacterset=utf8 a.jpg
or from Windows Latin2 (cp1250) to UTF-8:
exiftool -tagsfromfile @ -iptc:all -codedcharacterset=utf8 \ -charset iptc=latin2 a.jpg
and this command changes it back from UTF-8 to Windows Latin1 (cp1252):
exiftool -tagsfromfile @ -iptc:all -codedcharacterset= a.jpg
or to Windows Latin2:
exiftool -tagsfromfile @ -iptc:all -codedcharacterset= \ -charset iptc=latin2 a.jpg
Unless CodedCharacterSet is 'UTF8', applications have no reliable way to determine the IPTC character encoding. For this reason, it is recommended that CodedCharacterSet be set to 'UTF8' when creating new IPTC.
(Note: Here, "IPTC" Refers to the older IPTC IIM format. The more recent IPTC Core and Extension specifications actually use the XMP format.)
ExifTool reads XMP encoded as UTF-8, UTF-16 or UTF-32, and converts them all to UTF-8 internally. Also, all XML character entity references and numeric character references are converted. When writing, ExifTool always encodes XMP as UTF-8, converting the following 5 characters to XML character references: & < > ' ". By default no further conversion is performed, however if the "Charset" option is other than 'UTF8' then text is converted to/from the specified character set when reading/writing.
PNG TextualData tags are stored as tEXt, zTXt and iTXt chunks in PNG images. The tEXt and zTXt chunks use ISO 8859-1 encoding, while iTXt uses UTF-8. When reading, ExifTool converts all PNG textual data to the character set specified by the "Charset" option. When writing, ExifTool generates a tEXt chunk (or zTXt with the "Compress" option) if the text doesn't contain special characters or if Latin encoding is specified; otherwise an iTXt chunk is used and the text is converted from the specified character set and stored as UTF-8.
The encoding for the JPEG Comment (COM segment) is not specified, so ExifTool reads/writes this text without conversion.
The ID3v1 specification officially supports only ISO 8859-1 encoding (a subset of Windows Latin1), although some applications may incorrectly use other character sets. By default ExifTool converts ID3v1 text from Latin to the character set specified by the "Charset" option. However, the internal ID3v1 charset may be specified with the "CharsetID3" option. The encoding for ID3v2 information is stored in the file, so ExifTool converts ID3v2 text from this encoding to the character set specified by the "Charset" option. ExifTool does not currently write ID3 information.
PDF text strings are stored in either PDFDocEncoding (similar to Windows Latin1) or Unicode (UCS-2). When reading, ExifTool converts to the character set specified by the "Charset" option. When writing, ExifTool encodes input text from the specified character set as Unicode only if the string contains special characters, otherwise PDFDocEncoding is used.
Some Photoshop resource names are stored as Pascal strings with unknown encoding. By default, ExifTool assumes MacRoman encoding and converts this to UTF-8, but the internal and external character sets may be specified with the "CharsetPhotoshop" and "Charset" options respectively.
QuickTime text strings may be stored in a variety of poorly document formats. ExifTool does its best to decode these according to the "Charset" option setting. For some QuickTime strings, ExifTool assumes a default encoding of MacRoman, but this may be changed with the "CharsetQuickTime" option.
AIFF strings are assumed to be stored in MacRoman, and are converted according to the "Charset" option when reading.
The internal encoding of RIFF strings (eg. in AVI and WAV files) is assumed to be Latin unless otherwise specified by the RIFF CSET chunk or the "CharsetRIFF" option.
MIE strings are stored as either UTF-8 or ISO 8859-1. When reading, UTF-8 strings are converted according to the "Charset" option, and ISO 8859-1 strings are never converted. When writing, input strings are converted from the specified character set to UTF-8. The resulting strings are stored as UTF-8 if they contain multi-byte UTF-8 character sequences, otherwise they are stored as ISO 8859-1.
Vorbis comments are stored as UTF-8, and are converted to the character set specified by the "Charset" option.
Copyright 2003-2021, Phil Harvey
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Many people have helped in the development of ExifTool through their bug reports, comments and suggestions, and/or additions to the code. See the ACKNOWLEDGEMENTS in the individual Image::ExifTool modules and in html/index.html of the Image::ExifTool distribution package for a list of people who have contributed to this project.
exiftool(1), Image::ExifTool::TagNames(3pm), Image::ExifTool::Shortcuts(3pm), Image::ExifTool::Shift(3pm), Image::Info(3pm), Image::MetaData::JPEG(3pm)
2021-04-24 | perl v5.32.1 |