A SERVICE OF

logo

172 Appendix A
High-Level Support for Exif and IPTC
Two MediaScript objects are provided to simplify the tasks of getting and setting
individual metadata items. These objects are provided to support IPTC and Exif metadata.
Each of these objects has a similar format, providing set<Tag> methods and get<Tag>
methods which set and get individual metadata fields, respectively. <Tag> represents the
name of the metadata tag to set or get.
The following section describes the general structure and common methods for both the
IPTCMetadata object and the ExifMetadata object. This is followed by descriptions of the
set<Tag> and get<Tag> methods for the IPTCMetadata and ExifMetadata objects.
Common Metadata Methods
The IPTCMetadata and ExifMetadata objects have several common methods allowing the
scripter to create documents, specify metadata for existing documents, extract a string
representation of the XML document, and validate the document. These operations are
summarized in the following table.
NOTE: Each metadata constructor constructs a blank metadata document of the appropriate type.
This document is not empty. It is a valid XML document for the appropriate metadata schema.
However, loadFromFile and loadFromMedia will leave the document in an empty state if the file
contains no metadata of the appropriate type.
var metadata = new IPTCMetadata();
var empty = metadata.isEmpty(); // returns false
metadata.loadFromFile(“img.jpg”);
if (!metadata.isEmpty())
{
// do something with metadata
}
else
Method Description
IPTCMetadata(validate) Constructs a blank IPTC metadata document. If validate is true,
the document is automatically validated in set<tag> methods.
ExifMetadata(validate) Constructs a blank Exif metadata document.
loadFromFile(filename) Load metadata object with data from the specified file.
loadFromMedia(media) Load metadata object with data from the specified media.
loadFromXML(xmlString) Load metadata object with data from the specified XML string.
blankDocument() Load metadata object with a valid blank document.
validate() Validates the document to the appropriate schema.
isEmpty() Returns true if the document is empty.