Oracle® Multimedia User's Guide 11g Release 1 (11.1) Part Number B28415-01 |
|
|
View PDF |
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.
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 allow 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 and for image archiving usages, as well as at the consumer level.
Storing metadata together 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 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:
EXIF
IPTC-IIM
XMP
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 as well as 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.
For more information about XMP, see the Adobe Systems Incorporated Web site at
For more information about RDF, see the Resource Description Framework Web page on the World Wide Web Consortium Web site at
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. See Oracle Multimedia Reference for complete definitions of the XML schemas supported by Oracle Multimedia.
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 Oracle XML DB Developer's Guide for more information.)
The following examples of metadata extraction and embedding make use of the photos
table. The photos
table is defined by the Photo Album sample application. The implementation of the Photo Album sample application is defined in the PL/SQL package named 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.
Before you can extract or embed metadata, you must create the table and columns where the metadata will 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 interMedia 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 that will 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;
The following Web sites provide information about standards and technologies related to working with metadata in images.
Dublin Core, a standard schema for Dublin core elements
Extensible Metadata Platform
Resource Description Framework (See RDF Primer)
The Digital Imaging and Communications in Medicine (DICOM) feature allows Oracle Multimedia to recognize standalone DICOM objects and extract the set of attributes related to patient, study, series, and equipment. Recognizing a DICOM object means that Oracle Multimedia can determine whether given binary data represents a standalone DICOM object. If it does, Oracle Multimedia can extract DICOM metadata from that DICOM object. The data can be stored as the content of an ORDImage object, or directly in a BLOB or a BFILE.
DICOM objects are objects that can store different types of data. Examples include patient administration information, waveforms, images, slices of 3-D volumes, video segments, and time-variant 3-D volumes. A standalone DICOM object must have a file header that conforms to the DICOM standard.
The current release adds a new ORDDicom object type. In addition, applications can use Oracle Multimedia Java and PL/SQL APIs to store, manage, and manipulate DICOM objects. For more information about these and other new Oracle Multimedia DICOM enhancements, see Oracle Multimedia DICOM Developer's Guide and Oracle Multimedia DICOM Java API Reference.
See Oracle Multimedia Reference for details about the DICOM methods, encoding rules, image format, and exceptions supported by Oracle Multimedia in Oracle Database 10g Release 2.
Oracle Multimedia supports metadata extraction for the DICM image file format. DICM is the Oracle Multimedia designation for the Digital Imaging and Communications in Medicine format. See Oracle Multimedia Reference for more information about the image file formats supported by Oracle Multimedia.
The following example of DICOM metadata extraction makes use of the medicalImages
table, which is defined in the sample PL/SQL code segments described in the following subsections.
The medicalImages
table stores two instances of an image: the full-size photograph and a thumbnail image. This table can also store one image metadata document. This document is stored in the column named metadata
, and represents DICOM image metadata from the DICM metadata format. The metadata
column is of type XMLType
, and it is bound to the corresponding metadata XML schema that Oracle Multimedia provides.
Before you can extract DICOM metadata, you must create the table and column where the metadata will be stored. The following PL/SQL code segment creates the medicalImages
table with one XMLTYPE column (metadata
) to store the DICOM image metadata, and two ORDIMAGE columns (image
and thumb
) for the original image and the thumbnail image, respectively. The metadata
column is bound to the XML schema stored at http://xmlns.oracle.com/ord/meta/dicomImage
, and is defined as the XML element DICOM_IMAGE
.
The code statements where the image metadata
column is defined and bound to the XML schema are highlighted in bold.
create table medicalImages( id number primary key, description VARCHAR2(40), metadata 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 interMedia metadata columns XMLType column metadata XMLSCHEMA "http://xmlns.oracle.com/ord/meta/dicomImage" ELEMENT "DICOM_IMAGE";
The following PL/SQL procedure extracts DICOM metadata from an image and stores it in the specified column in the medicalImages
table you created. This procedure demonstrates the getDicomMetadata( ) method, which returns an XML document. The UPDATE statement stores the document in the corresponding column in the medicalImages
table.
The code statement where the getDicomMetadata( ) method is called is highlighted in bold.
--
PROCEDURE extractDicomMetadata(inID INTEGER)
IS
local_image ORDSYS.ORDIMAGE;
local_id INTEGER;
dicom_metadata XMLType := NULL;
BEGIN
SELECT image INTO local_image FROM medicalImages WHERE id = inID;
-- extract DICOM metadata
dicom_metadata := local_image.getDicomMetadata('imageGeneral');
IF (dicom_metadata IS NULL) THEN
DBMS_OUTPUT.PUT_LINE('metadata is NULL');
ELSE
UPDATE medicalImages SET metadata = dicom_metadata where id = inID;
END IF;
-- let us print the namespace of the XML document containing the
-- dicom metadata that we just extracted
DBMS_OUTPUT.PUT_LINE('namespace: ' || dicom_metadata.getNamespace());
END extractDicomMetadata;
--