Oracle® Multimedia User's Guide 11g Release 2 (11.2) Part Number E10777-03 |
|
|
PDF · Mobi · ePub |
Image files can contain information about the content of the images, the image rasters, and image metadata. In general, data about data is referred to as metadata. In this case, metadata refers to additional information about the actual images, which is stored in the image files along with the images.
This chapter includes these sections:
Several types of metadata can be stored in an image file, and each type can serve a different purpose. One type, technical metadata, is used to describe an image in a technical sense. For example, technical metadata can include attributes about an image, such as its height and width, in pixels, or the type of compression used to store it. Another type, content metadata, can further describe the content of an image, the name of the photographer, and the date and time when a photograph was taken.
Metadata is stored in image files using a variety of mechanisms. Digital cameras and scanners automatically insert metadata into the images they create. Digital photograph processing applications like Adobe Photoshop enable users to add or edit metadata to be stored with the image. Annotating digital images with additional metadata is a common practice in photographic and news gathering applications, for image archiving usages, and at the consumer level.
Storing metadata with image data in the same containing file provides encapsulation. With encapsulation, both types of data can be shared and exchanged reliably as one unit. Metadata that is stored in the image file format is referred to as embedded metadata.
For a large number of image file formats, Oracle Multimedia can extract and manage a limited set of metadata attributes. These attributes include: height, width, contentLength, fileFormat, contentFormat, compressionFormat, and mimeType. For a limited number of image file formats, Oracle Multimedia can extract a rich set of metadata attributes. This metadata is represented in schema-based XML documents. These XML documents can be stored in a database, indexed, searched, updated, and made available to applications using the standard mechanisms of Oracle Database.
Oracle Multimedia can also write or embed metadata supplied by users into a limited number of image file formats. The application provides the metadata as a schema-based XML document. Oracle Multimedia processes the XML document and writes the metadata into the image file.
Oracle Multimedia supports metadata extraction and metadata embedding for the GIF, TIFF, and JPEG file formats.
See Also:
Oracle Multimedia Reference for information about the image file formats supported by Oracle Multimedia
The term image metadata format refers to the standard protocols and techniques used to store image metadata within an image file. The following subsections describe the embedded image metadata formats supported by Oracle Multimedia:
The Exchangeable Image File Format (EXIF) is the standard for image file storage for digital still cameras. It was developed by the Japan Electronic Industry Development Association (JEIDA) as a standard way of storing images created by digital cameras and metadata about the images. EXIF image metadata can be stored in TIFF and JPEG format images. Oracle Multimedia supports the extraction of EXIF metadata from TIFF and JPEG file formats.
The International Press Telecommunications Council-Information Interchange Model (IPTC-IIM) Version 4 is a standard developed jointly by the International Press Telecommunications Council and the Newspaper Association of America. This metadata standard is designed to capture information that is important to the activities of news gathering, reporting, and publishing. These information records are commonly referred to as IPTC tags.
The use of embedded IPTC tags in image file formats became widespread with the use of the Adobe Photoshop tool for image editing. IPTC metadata can be stored in TIFF and JPEG format images. Oracle Multimedia supports the extraction of IPTC metadata from TIFF and JPEG file formats.
The Extensible Metadata Platform (XMP) is a standard metadata format, developed by Adobe, for the creation, processing, and interchange of metadata in a variety of applications. XMP uses Resource Description Framework (RDF) technology for data modeling. XMP also defines how the data model is serialized (converted to a byte stream), and embedded within an image file. Oracle Multimedia supports the extraction of XMP metadata from GIF, TIFF, and JPEG file formats. Oracle Multimedia also supports writing XMP data packets into GIF, TIFF, and JPEG file formats.
See Also:
http://www.adobe.com/
for more information about the Extensible Metadata Platform
http://www.w3.org/RDF/
for more information about Resource Description Framework technology
After metadata has been extracted from the binary image file, the next step is to represent the metadata in a form that can be easily stored, indexed, queried, updated, and presented. Oracle Multimedia returns image metadata in XML documents. These documents are based on XML schemas that Oracle Multimedia registers with the database. Each type of image metadata has a separate XML schema. These XML schemas are used by the metadata methods of the ORDImage object type.
The XML documents can be stored in XMLType columns within the database. These documents are easily searched and processed using the wide range of standards-based XML technologies provided by Oracle XML DB.
See Also:
Oracle Multimedia Reference for complete definitions of the XML schemas supported by Oracle Multimedia
Oracle XML DB Developer's Guide for more information about the XML technologies provided by Oracle XML DB
The following examples of metadata extraction and embedding use the photos
table, which is defined by the Photo Album sample application. The implementation of the Photo Album sample application is defined in the PL/SQL package PHOTO_ALBUM
. See Section 3.1 for a complete description of the Oracle Multimedia PL/SQL Web Toolkit Photo Album sample application.
The photos
table stores two instances of an image: the full-size photograph and a thumbnail image. This table can also store up to four different image metadata documents. These documents are stored in the columns named metaORDImage
, metaEXIF
, metaIPTC
, and metaXMP
, and represent image metadata from the ORDImage, EXIF, IPTC, and XMP metadata formats, respectively. The metadata columns are of type XMLType, and they are bound to the corresponding metadata XML schemas that Oracle Multimedia provides.
The following subsections describe some operations you can perform with image metadata:
Before you can extract or embed metadata, you must create the table and columns where the metadata is to be stored. The following PL/SQL code segment creates the photos
table with four XMLTYPE columns (metaORDImage
, metaEXIF
, metaIPTC
, and metaXMP
) to store each type of image metadata, and two ORDIMAGE columns (image
and thumb
) for the original image and the thumbnail image, respectively. Each metadata column is bound to its corresponding metadata schema. For example, the metaEXIF
column is bound to the XML schema stored at http://xmlns.oracle.com/ord/meta/exif
, and is defined as the XML element exifMetadata
.
The code statements where the image metadata columns are defined and bound to XML schemas are highlighted in bold.
-- -- Create the PHOTOS table -- CREATE TABLE photos( id NUMBER PRIMARY KEY, description VARCHAR2(40) NOT NULL, metaORDImage XMLTYPE, metaEXIF XMLTYPE, metaIPTC XMLTYPE, metaXMP XMLTYPE, image ORDSYS.ORDIMAGE, thumb ORDSYS.ORDIMAGE ) -- -- store full-size images and thumbnail images as SecureFile LOBs -- LOB(image.source.localdata) STORE AS SECUREFILE LOB(thumb.source.localdata) STORE AS SECUREFILE -- and bind the XMLType columns to the Oracle Multimedia metadata schemas XMLType COLUMN metaORDImage XMLSCHEMA "http://xmlns.oracle.com/ord/meta/ordimage" ELEMENT "ordImageAttributes" XMLType COLUMN metaEXIF XMLSCHEMA "http://xmlns.oracle.com/ord/meta/exif" ELEMENT "exifMetadata" XMLType COLUMN metaIPTC XMLSCHEMA "http://xmlns.oracle.com/ord/meta/iptc" ELEMENT "iptcMetadata" XMLType COLUMN metaXMP XMLSCHEMA "http://xmlns.oracle.com/ord/meta/xmp" ELEMENT "xmpMetadata";
The following PL/SQL procedure extracts metadata from an image and stores it in the specified columns in the photos
table you created. This procedure demonstrates the getMetadata( ) method, which returns an array of XML documents. The root element of each document is examined to determine the metadata type. The UPDATE statement stores the documents in the corresponding columns in the photos
table.
The code statement where the getMetadata( ) method is called is highlighted in bold.
--
-- fetch the metadata and sort the results
--
PROCEDURE extractMetadata(inID IN INTEGER)
IS
img ORDSYS.ORDIMAGE;
metav XMLSequenceType;
meta_root VARCHAR2(40);
xmlORD XMLType;
xmlXMP XMLType;
xmlEXIF XMLType;
xmlIPTC XMLType;
BEGIN
-- select the image
SELECT image
INTO img
FROM PHOTOS
WHERE id = inID;
-- extract all the metadata
metav := img.getMetadata( 'ALL' );
-- process the result array to discover what types of metadata were
returned
FOR i IN 1..metav.count() LOOP
meta_root := metav(i).getRootElement();
CASE meta_root
WHEN 'ordImageAttributes' THEN xmlORD := metav(i);
WHEN 'xmpMetadata' THEN xmlXMP := metav(i);
WHEN 'iptcMetadata' THEN xmlIPTC := metav(i);
WHEN 'exifMetadata' THEN xmlEXIF := metav(i);
ELSE NULL;
END CASE;
END LOOP;
-- Update metadata columns
--
UPDATE photos
SET metaORDImage = xmlORD,
metaEXIF = xmlEXIF,
metaIPTC = xmlIPTC,
metaXMP = xmlXMP
WHERE id = inID;
END extractMetadata;
The following PL/SQL procedure demonstrates the putMetadata( ) method. This procedure accepts six arguments. The entry_id
argument identifies the image in the photos
table to be updated. The remaining arguments (title
, creator
, date
, description
, and copyright
) are strings to be formatted into an XMP packet and embedded within the target image.
This example creates an XML document instance based on the Oracle Multimedia XML schema for XMP metadata. (This schema is preregistered with Oracle XML DB. See Oracle XML DB Developer's Guide for more information.) The schema for XMP metadata defines a single, global element <xmpMetadata>
. The <xmpMetadata> element contains a single, well-formed RDF document. The RDF document contains a single <RDF>
element, which is derived from the rdf
namespace. This RDF document is constructed using elements defined by the Dublin Core Schema.
The call to the putMetadata( ) method embeds the metadata document into the image file. The UPDATE statement stores the new image and the new metadata back in the photos
table.
The code statement where the putMetadata( ) method is called is highlighted in bold.
--
-- write the metadata to the image
--
PROCEDURE write_metadata( entry_id IN VARCHAR2,
title IN VARCHAR2,
creator IN VARCHAR2,
date IN VARCHAR2,
description IN VARCHAR2,
copyright IN VARCHAR2 )
IS
img ORDSYS.ORDImage;
xmp XMLType;
buf VARCHAR2(5000);
BEGIN
-- select the image
SELECT image
INTO img
FROM PHOTOS
WHERE id = entry_id FOR UPDATE;
-- Create the XMP packet it must be schema valid
-- to "http://xmlns.oracle.com/ord/meta/xmp"
-- and contain an <RDF> element. This example uses
-- the Dublin Core schema.
/* An example XML instance document
<xmpMetadata xmlns="http://xmlns.oracle.com/ord/meta/xmp"
xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/xmp
http://xmlns.oracle.com/ord/meta/xmp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description about="" xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>A Winter Day</dc:title>
<dc:creator>Frosty S. Man</dc:creator>
<dc:date>21-Dec-2004</dc:date>
<dc:description>a sleigh ride</dc:description>
<dc:copyright>North Pole Inc.</dc:copyright>
</rdf:Description>
</rdf:RDF>
</xmpMetadata>
*/
buf := '<xmpMetadata xmlns="http://xmlns.oracle.com/ord/meta/xmp"
xsi:schemaLocation="http://xmlns.oracle.com/ord/meta/xmp
http://xmlns.oracle.com/ord/meta/xmp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description about="" xmlns:dc="http://purl.org/dc/elements/1.1/">';
IF title IS NOT NULL THEN
buf := buf || '<dc:title>' || htf.escape_sc(title) || '</dc:title>';
END IF;
IF creator IS NOT NULL THEN
buf := buf || '<dc:creator>' || htf.escape_sc(creator)
|| '</dc:creator>';
END IF;
IF date IS NOT NULL THEN
buf := buf || '<dc:date>' || htf.escape_sc(date)
|| '</dc:date>';
END IF;
IF description IS NOT NULL THEN
buf := buf || '<dc:description>' || htf.escape_sc(description)
|| '</dc:description>';
END IF;
IF copyright IS NOT NULL THEN
buf := buf || '<dc:copyright>' || htf.escape_sc(copyright)
|| '</dc:copyright>';
END IF;
buf := buf || '
</rdf:Description>
</rdf:RDF>
</xmpMetadata>';
-- create the XML document
xmp := XMLType.createXML(buf, 'http://xmlns.oracle.com/ord/meta/xmp');
-- write the metadata
img.putMetadata( xmp, 'XMP' );
-- update the image
UPDATE photos
SET image = img,
metaXMP = xmp
WHERE id = entry_id;
END write_Metadata;