Oracle® Multimedia Reference 11g Release 1 (11.1) Part Number B28414-01 |
|
|
View PDF |
Oracle Multimedia contains the following information about the ORDImage object type:
The examples in this chapter use the ONLINE_MEDIA table in the Product Media sample schema. To replicate the examples on your own computer, you should begin with the examples shown in the reference pages for the ORDImage constructors and the import( ) and importFrom( ) methods. Substitute image files you have for the ones shown in the examples. In addition, for a user ron
to use the examples, the following statements must be issued before ron
executes the examples, where /mydir/work
is the directory where ron
will find the image data:
CONNECT /as sysdba CREATE OR REPLACE DIRECTORY FILE_DIR as '/mydir/work'; GRANT READ ON DIRECTORY FILE_DIR TO 'ron';
See Oracle Database Sample Schemas for information about the sample schemas.
Note:
If you manipulate the image data itself (by either directly modifying the BLOB or changing the external source), then you must ensure that the object attributes stay synchronized and the update time is modified; otherwise, the object attributes will not match the image data.Methods invoked at the ORDSource level that are handed off to the source plug-in for processing have ctx (RAW) as the first argument. Before calling any of these methods for the first time, the client should allocate the ctx structure, initialize it to NULL, and invoke the openSource( ) method. At this point, the source plug-in can initialize the context for this client. When processing is complete, the client should invoke the closeSource( ) method.
Methods invoked from a source plug-in call have the first argument as ctx (RAW).
Note:
In the current release, none of the plug-ins provided by Oracle and not all source or format plug-ins will use the ctx argument, but if you code as previously described, your application should work with current or future source or format plug-ins.You should use any of the individual set methods to set the attribute value for an object for formats not natively supported; otherwise, for formats natively supported, use the setProperties( ) method to populate the attributes of the object or write a format plug-in.
Oracle Multimedia describes the ORDImage object type, which supports the storage, management, and manipulation of image data. This object type is defined as follows in the ordispec.sql
file:
CREATE OR REPLACE TYPE ORDImage AS OBJECT ( ------------------- -- TYPE ATTRIBUTES ------------------- source ORDSource, height INTEGER, width INTEGER, contentLength INTEGER, fileFormat VARCHAR2(4000), contentFormat VARCHAR2(4000), compressionFormat VARCHAR2(4000), mimeType VARCHAR2(4000), --------------------- -- METHOD DECLARATION --------------------- -- CONSTRUCTORS -- STATIC FUNCTION init( ) RETURN ORDImage, STATIC FUNCTION init(srcType IN VARCHAR2, srcLocation IN VARCHAR2, srcName IN VARCHAR2) RETURN ORDImage, -- -- Methods associated with copy operations MEMBER PROCEDURE copy(dest IN OUT ORDImage), -- -- Methods associated with image processing operations MEMBER PROCEDURE process(command IN VARCHAR2), -- MEMBER PROCEDURE processCopy(command IN VARCHAR2, dest IN OUT ORDImage), -- -- Methods associated with image property set and check operations MEMBER PROCEDURE setProperties( ), MEMBER PROCEDURE setProperties(description IN VARCHAR2), MEMBER FUNCTION checkProperties RETURN BOOLEAN, -- -- Methods associated with image attributes accessors MEMBER FUNCTION getHeight RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getHeight, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getWidth RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getWidth, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getFileFormat RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getFileFormat, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getContentFormat RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getContentFormat, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getCompressionFormat RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getCompressionFormat, WNDS, WNPS, RNDS, RNPS), -- -- Methods associated with metadata attributes MEMBER FUNCTION getMetadata(metadataType IN VARCHAR2 DEFAULT 'ALL') RETURN SYS.XMLSEQUENCETYPE, -- MEMBER PROCEDURE putMetadata(xmlData IN SYS.XMLType, metadataType IN VARCHAR2 DEFAULT 'XMP', encoding IN VARCHAR2 DEFAULT 'UTF-8'), -- -- Methods associated with the local attribute MEMBER PROCEDURE setLocal( ), MEMBER PROCEDURE clearLocal( ), MEMBER FUNCTION isLocal RETURN BOOLEAN, PRAGMA RESTRICT_REFERENCES(isLocal, WNDS, WNPS, RNDS, RNPS), -- -- Methods associated with the date attribute MEMBER FUNCTION getUpdateTime RETURN DATE, PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setUpdateTime(current_time DATE), -- -- Methods associated with the mimeType attribute MEMBER FUNCTION getMimeType RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setMimeType(mime IN VARCHAR2), -- -- Methods associated with the source attribute MEMBER FUNCTION getContentLength RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getContent RETURN BLOB, PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getBFILE RETURN BFILE, PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS), -- MEMBER PROCEDURE deleteContent( ), -- MEMBER FUNCTION getDicomMetadata(optionString IN VARCHAR2) RETURN XMLType, -- MEMBER PROCEDURE setSource(source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER FUNCTION getSource RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getSourceType RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getSourceLocation RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS, WNPS, RNDS, RNPS), -- MEMBER FUNCTION getSourceName RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS, WNPS, RNDS, RNPS), -- MEMBER PROCEDURE import(ctx IN OUT RAW), MEMBER PROCEDURE importFrom(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER PROCEDURE export(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), -- MEMBER FUNCTION processSourceCommand( ctx IN OUT RAW, cmd IN VARCHAR2, arguments IN VARCHAR2, result OUT RAW) RETURN RAW, -- -- Methods associated with file operations on the source MEMBER FUNCTION openSource(userArg IN RAW, ctx OUT RAW) RETURN INTEGER, -- MEMBER FUNCTION closeSource(ctx IN OUT RAW) RETURN INTEGER, -- MEMBER FUNCTION trimSource(ctx IN OUT RAW, newlen IN INTEGER) RETURN INTEGER, -- MEMBER PROCEDURE readFromSource(ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer OUT RAW), -- MEMBER PROCEDURE writeToSource(ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer IN RAW), );
where:
source: the source of the stored image data.
height: the height of the image in pixels.
width: the width of the image in pixels.
contentLength: the size of the image file on disk, in bytes.
fileFormat: the file type or format in which the image data is stored (TIFF, JIFF, and so forth).
contentFormat: the type of image (monochrome and so forth).
compressionFormat: the compression algorithm used on the image data.
mimeType: the MIME type information.
This section describes the ORDImage constructor functions, which are the following:
Format
init( ) RETURN ORDImage;
Description
Initializes instances of the ORDImage object type.
Parameters
None.
Pragmas
None.
Exceptions
None.
Usage Notes
This constructor is a static method that initializes all the ORDImage attributes to NULL with the following exceptions:
source.updateTime is set to SYSDATE
source.local is set to 1 (local)
source.localData is set to empty_blob
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDImage object type, especially if the ORDImage type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Examples
Initialize the ORDImage object attributes:
BEGIN INSERT INTO pm.online_media (product_id, product_photo) VALUES (3501, ORDSYS.ORDImage.init()); COMMIT;END;/
Format
init(srcType IN VARCHAR2,
srcLocation IN VARCHAR2,
srcName IN VARCHAR2)
RETURN ORDImage;
Description
Initializes instances of the ORDImage object type.
Parameters
The source type of the image data.
The source location of the image data.
The source name of the image data.
Pragmas
None.
Exceptions
None.
Usage Notes
This constructor is a static method that initializes all the ORDImage attributes to NULL with the following exceptions:
source.updateTime is set to SYSDATE
source.local is set to 0
source.localData is set to empty_blob
source.srcType is set to the input value
source.srcLocation is set to the input value
source.srcName is set to the input value
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDImage object type, especially if the ORDImage type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Examples
Initialize the ORDImage object attributes:
BEGIN INSERT INTO pm.online_media (product_id, product_photo) VALUES (3515, ORDSYS.ORDImage.init('FILE', 'FILE_DIR','speaker.jpg')); COMMIT; END; /
This section presents reference information on the Oracle Multimedia methods used specifically for image data manipulation.
Chapter 2 presents reference information on the Oracle Multimedia methods that are common to ORDAudio, ORDDoc, ORDImage, and ORDVideo. Use the methods presented in both chapters to get and set attributes, perform processing operations, and perform metadata extractions.
The following methods are presented in this section:
Format
checkProperties( ) RETURN BOOLEAN;
Description
Verifies that the properties stored in attributes of the image object match the properties of the image. This method should not be used for foreign images (those formats not natively supported by Oracle Multimedia).
Parameters
None.
Usage Notes
Use this method to verify that the image attributes match the actual image.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about this exception.
Examples
Check the image attributes:
DECLARE image ORDSYS.ORDImage; properties_match BOOLEAN; BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- check that properties match the image properties_match := image.checkProperties(); IF properties_match THEN DBMS_OUTPUT.PUT_LINE('Check Properties succeeded'); ELSE DBMS_OUTPUT.PUT_LINE('Check Properties failed'); END IF; COMMIT; END; /
Format
copy(dest IN OUT ORDImage);
Description
Copies an image without changing it.
Parameters
The destination of the new image.
Usage Notes
This method copies the image data, as is, including all source and image attributes, into the supplied local destination image.
If the data is stored locally in the source, then calling this method copies the BLOB to the destination source.localData attribute.
Calling this method copies the external source information to the external source information of the new image, whether or not source data is stored locally.
Calling this method implicitly calls the setUpdateTime( ) method on the destination object to update its time stamp information.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about this exception.
Examples
Create a copy of an image:
DECLARE image_1 ORDSYS.ORDImage; image_2 ORDSYS.ORDImage; BEGIN -- Initialize a new ORDImage object where the copy will be stored: INSERT INTO pm.online_media (product_id, product_photo) VALUES (3091, ORDSYS.ORDImage.init()); -- Select the source object into image_1: SELECT product_photo INTO image_1 FROM pm.online_media WHERE product_id = 3515; -- Select the target object into image_2: SELECT product_photo INTO image_2 FROM pm.online_media WHERE product_id = 3091 FOR UPDATE; -- Copy the data from image_1 to image_2: image_1.copy(image_2); UPDATE pm.online_media SET product_photo = image_2 WHERE product_id = 3091; COMMIT; END; /
Format
getCompressionFormat( ) RETURN VARCHAR2;
Description
Returns the value of the compressionFormat attribute of the image object.
Parameters
None.
Usage Notes
Use this method rather than accessing the compressionFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getCompressionFormat, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the compression type of an image:
DECLARE image ORDSYS.ORDImage; compression_format VARCHAR2(4000); BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image compression format: compression_format := image.getCompressionFormat(); DBMS_OUTPUT.PUT_LINE('Compression format is ' || compression_format); COMMIT; END; /
Format
getContentFormat( ) RETURN VARCHAR2;
Description
Returns the value of the contentFormat attribute of the image object.
Parameters
None.
Usage Notes
Use this method rather than accessing the contentFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getContentFormat, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the content type of an image:
DECLARE image ORDSYS.ORDImage; content_format VARCHAR2(4000); BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image content format: content_format := image.getContentFormat(); DBMS_OUTPUT.PUT_LINE('Content format is ' || content_format); COMMIT; END; /
Format
getContentLength( ) RETURN INTEGER;
Description
Returns the value of the contentLength attribute of the image object.
Parameters
None.
Usage Notes
Use this method rather than accessing the contentLength attribute directly to protect from potential future changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the content length of an image:
DECLARE image ORDSYS.ORDImage; content_length INTEGER; BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image size: content_length := image.getContentLength(); DBMS_OUTPUT.PUT_LINE('Content length is ' || content_length); COMMIT; END; /
Format
getDicomMetadata(optionString IN VARCHAR2) RETURN XMLType ;
Description
Returns an XML representation of the metadata extracted from the DICOM image stored in the ORDImage object. See Appendix F for information about the XML schema for DICOM.
Parameters
A string that specifies the type of DICOM metadata to extract. For this release, the only valid value is imageGeneral
. All other values are ignored.
Usage Notes
The DICOM standard defines many sets of rules for encoding a DICOM object in a binary stream. See Appendix G for information about the DICOM encoding rules supported by Oracle Multimedia.
See Oracle Multimedia User's Guide for more information about the Oracle Multimedia DICOM feature.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised when source.localData is NULL.
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
DECLARE local_image ORDSYS.ORDIMAGE; local_id INTEGER; dicom_metadata XMLType := NULL; BEGIN SELECT image INTO local_image FROM medicalImages WHERE id = 1; dicom_metadata := local_image.getDicomMetadata('imageGeneral'); IF (dicom_metadata is NULL) THEN DBMS_OUTPUT.PUT_LINE('dicom metadata is NULL'); END IF; -- print the value of the one of the elements in extracted -- dicom metadata DBMS_OUTPUT.PUT_LINE('namespace: ' || dicom_metadata.getNamespace() ); EXCEPTION WHEN ORDSYS.ORDImageExceptions.NULL_LOCAL_DATA THEN DBMS_OUTPUT.PUT_LINE('source local data is null '); WHEN ORDSYS.ORDImageExceptions.NULL_SOURCE THEN DBMS_OUTPUT.PUT_LINE('source is null '); WHEN OTHERS THEN RAISE; END;/
Format
getFileFormat( ) RETURN VARCHAR2;
Description
Returns the value of the fileFormat attribute of the image object.
Parameters
None.
Usage Notes
Use this method rather than accessing the fileFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getFileFormat, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the file type of an image:
DECLARE image ORDSYS.ORDImage; file_format VARCHAR2(4000); BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image file format: file_format := image.getFileFormat(); DBMS_OUTPUT.PUT_LINE('File format is ' || file_format); COMMIT; END; /
Format
getHeight( ) RETURN INTEGER;
Description
Returns the value of the height attribute of the image object.
Parameters
None.
Usage Notes
Use this method rather than accessing the height attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getHeight, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the height of an image:
DECLARE image ORDSYS.ORDImage; height INTEGER; BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image height: height := image.getHeight(); DBMS_OUTPUT.PUT_LINE('Height is ' || height); COMMIT; END; /
Format
getMetadata(metadataType IN VARCHAR2 DEFAULT 'ALL' ) RETURN XMLSequenceType ;
Description
Extracts the specified types of metadata from the image and returns an array of schema valid XML documents. If no matching metadata is found, an empty array is returned.
Parameters
A string that specifies the types of embedded metadata to extract. Valid values are ALL, ORDIMAGE, XMP, EXIF, and IPTC-IIM. The default value is ALL.
Usage Notes
When the value of the input parameter metadataType is ALL, and more than one type of supported metadata is present in the image, this method returns several XML documents, one for each type of metadata found. For other values of the input parameter, the method returns zero or one XML document.
Each document is stored as an instance of XMLType, and is based on one of the metadata schemas. The method XMLType.getNamespace( ) can be used to determine the type of metadata represented in that document.
See Appendix F for a description of the supported metadata schemas.
See Oracle Multimedia User's Guide for more information about the metadata feature.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised when source.localData is NULL.
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
DECLARE image ORDSYS.ORDImage; metav XMLSequenceType; BEGIN SELECT product_photo INTO image FROM pm.online_media WHERE product_id = 3106; metav := image.getMetadata('ALL'); -- print the namespace of each metadata document FOR i in 1..metav.count LOOP DBMS_OUTPUT.PUT_LINE('namespace: ' || metav(i).getNamespace() ); END LOOP; EXCEPTION WHEN ORDSYS.ORDImageExceptions.NULL_LOCAL_DATA THEN DBMS_OUTPUT.PUT_LINE('source local data is null'); WHEN ORDSYS.ORDImageExceptions.NULL_SOURCE THEN DBMS_OUTPUT.PUT_LINE('source is null'); WHEN OTHERS THEN RAISE; END; /
Format
getWidth( ) RETURN INTEGER;
Description
Returns the value of the width attribute of the image object
Parameters
None.
Usage Notes
Use this method rather than accessing the width attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
Pragmas
PRAGMA RESTRICT_REFERENCES(getWidth, WNDS, WNPS, RNDS, RNPS)
Exceptions
None.
Examples
Get the width of an image:
DECLARE image ORDSYS.ORDImage; width INTEGER; BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515; -- Get the image width: width := image.getWidth(); DBMS_OUTPUT.PUT_LINE('Width is ' || width); COMMIT; END; /
Format
import(ctx IN OUT RAW);
Description
Transfers image data from an external image data source to the localData attribute (of the embedded ORDSource object) within the database.
Parameters
The source plug-in context information. This should be allocated and initialized to NULL. If you are using a user-defined source plug-in, call the openSource( ) method. See Section 5.2 for more information.
Usage Notes
Use the setSource( ) method to set the source.srcType, source.srcLocation, and source.srcName attributes (of the embedded ORDSource object) for the external image data source prior to calling the import( ) method.
You must ensure that the directory exists or is created before you use this method for a source.srcType attribute with a value of "file".
After importing data from an external image data source to a local source (within Oracle Database), the source information remains unchanged (that is, pointing to the source from where the data was imported).
Invoking this method implicitly calls the setUpdateTime( ) and setLocal( ) methods.
If the file format of the imported image is not previously set to a string beginning with "OTHER", the setProperties( ) method is also called. Set the file format to a string preceded by "OTHER" for foreign image formats; calling the setProperties( ) method for foreign images does this for you.
This method is invoked at the ORDSource level, which uses the PL/SQL UTL_HTTP package to import media data from an HTTP data source. You can use environment variables to specify the proxy behavior of the UTL_HTTP package. For example, on Linux and UNIX, setting the environment variable http_proxy to a URL specifies that the UTL_HTTP package will use that URL as the proxy server for HTTP requests. Setting the no_proxy environment variable to a domain name specifies that the HTTP proxy server will not be used for URLs in the specified domain.
See Oracle Database PL/SQL Packages and Types Reference for more information about the UTL_HTTP PL/SQL package.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the import( ) method and the value of the source.srcType attribute is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the import( ) method and this method is not supported by the source plug-in being used.
See Appendix H for more information about these exceptions.
Examples
Import image data from an external image data source into the local source:
DECLARE obj ORDSYS.ORDImage; ctx RAW(64) :=NULL; BEGIN SELECT p.product_photo INTO obj FROM pm.online_media p WHERE p.product_id = 3515 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- Get source information DBMS_OUTPUT.PUT_LINE(obj.getSource()); -- Import data obj.import(ctx); -- Check size DBMS_OUTPUT.PUT_LINE('Length is ' || obj.getContentLength()); UPDATE pm.online_media p SET p.product_photo = obj WHERE p.product_id = 3515; COMMIT; END; /
Format
importFrom(ctx IN OUT RAW,
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2);
Description
Transfers image data from the specified external image data source to the source.localData attribute (of the embedded ORDSource object) within the database.
Parameters
The source plug-in context information. This should be allocated and initialized to NULL. If you are using a user-defined source plug-in, call the openSource( ) method. See Section 5.2 for more information.
The type of the source image data.
The location from which the source image data is to be imported.
The name of the source image data.
Usage Notes
This method is similar to the import( ) method except the source information is specified as parameters to the method instead of separately.
You must ensure that the directory exists or is created before you use this method with a source_type parameter value of "file".
After importing data from an external image data source to a local source (within Oracle Database), the source information (that is, pointing to the source from where the data was imported) is set to the input values.
Invoking this method implicitly calls the setUpdateTime( ) and setLocal( ) methods.
If the file format of the imported image is not previously set to a string beginning with "OTHER", the setProperties( ) method is also called. Set the file format to a string preceded by "OTHER" for foreign image formats; calling the setProperties( ) for foreign images method does this for you.
This method is invoked at the ORDSource level, which uses the PL/SQL UTL_HTTP package to import media data from an HTTP data source. You can use environment variables to specify the proxy behavior of the UTL_HTTP package. For example, on Linux and UNIX, setting the environment variable http_proxy to a URL specifies that the UTL_HTTP package will use that URL as the proxy server for HTTP requests. Setting the no_proxy environment variable to a domain name specifies that the HTTP proxy server will not be used for URLs in the specified domain.
See Oracle Database PL/SQL Packages and Types Reference for more information about the UTL_HTTP PL/SQL package.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the importFrom( ) method and this method is not supported by the source plug-in being used.
See Appendix H for more information about these exceptions.
Examples
Import image data from the specified external data source into the local source:
DECLARE obj ORDSYS.ORDImage; ctx RAW(64) :=NULL; BEGIN SELECT p.product_photo INTO obj FROM pm.online_media p WHERE p.product_id = 3501 FOR UPDATE; -- set source to a file -- import data obj.importFrom(ctx,'file','FILE_DIR','speaker.jpg'); -- check size DBMS_OUTPUT.PUT_LINE('Length is ' || obj.getContentLength()); DBMS_OUTPUT.PUT_LINE('Source is ' || obj.getSource()); UPDATE pm.online_media p SET p.product_photo = obj WHERE p.product_id = 3501; COMMIT; END; /
Format
process(command IN VARCHAR2);
Description
Performs one or more image processing operations on a BLOB, writing the image back onto itself.
Parameters
A list of image processing operations to perform on the image.
Usage Notes
There is no implicit import( ) or importFrom( ) call performed when you call this method; if data is external, you must first call the import( ) or importFrom( ) method to make the data local before you can process it.
Implicit setProperties( ), setUpdateTime( ), and setMimeType( ) methods are done after the process( ) method is called.
You can change one or more of the image attributes shown in Table 5-1.
Table 5-1 Image Processing Operators
Operator Name | Usage | Values |
---|---|---|
Forces output to the specified compression format if it is supported by the output file format. (See Section D.2.3.) |
JPEG, SUNRLE, BMPRLE, TARGARLE, LZW, LZWHDIFF, FAX3, FAX4, HUFFMAN3, PACKBITS, GIFLZW, ASCII, RAW, DEFLATE, NONE |
|
Determines the quality of lossy compression; for use with JPEG only. (See Section D.2.4.) |
MAXCOMPRATIO, MAXINTEGRITY, LOWCOMP, MEDCOMP, HIGHCOMP, or an integer value between 0 and 100. |
|
Determines the format of the image content. (See Section D.2.2.) |
See Section D.2.2 for values. |
|
Adjusts image contrast. (See Section D.3.1.)Foot 1 |
nonnegative FLOATFoot 2 , nonnegative FLOAT FLOAT FLOATFoot 3 , nonnegative FLOAT FLOATFoot 4 , nonnegative FLOAT FLOAT FLOAT FLOAT FLOAT FLOATFoot 5 |
|
Defines a window to cut or crop (origin.x origin.y width height); first pixel in x or y is 0 (zero); must define a window inside image. (See Section D.3.2.) |
nonnegative INTEGER INTEGER INTEGER INTEGER maximum value is 2147483648 |
|
Forces the output to specified file format. (See Section D.2.1.) |
BMPF, CALS, GIFF, JFIF, PBMF, PGMF, PICT, PNGF, PNMF, PPMF, RASF, RPIX, TGAF, TIFF, WBMP |
|
Scales an image to a specified size in pixels (width, height); may not be combined with other scale operators. (See Section D.3.9.1.) |
positive INTEGER INTEGER |
|
Places the scanlines of an image in inverse order -- swapped top to bottom. (See Section D.3.3.) |
No arguments |
|
Adjusts gamma (brightness) of an image. (See Section D.3.4.)Foot 6 |
||
Scales an image to a specified size in pixels (width, height), while maintaining the aspect ratio; may not be combined with other scale operators. (See Section D.3.9.2.) |
positive INTEGER INTEGER |
|
Places columns of an image in reverse order -- swapped left to right. (See Section D.3.5.) |
No arguments |
|
Selects a page from a multipage file; for use with TIFF only; first page is 0 (zero). (See Section D.3.6.) |
nonnegative INTEGER |
|
Specifies how image quantization is to be performed when reducing image bit depth. (See Section D.3.7.) |
ERRORDIFFUSION (default), ORDEREDDITHER, THRESHOLD, MEDIANCUT |
|
Rotates an image within the image plane by the angle specified. (See Section D.3.8.)Foot 9 |
FLOAT |
|
Uniformly scales an image by a given factor (for example, 0.5 or 2.0); may not be combined with other scale operators. (See Section D.3.9.3.)Foot 10 |
positive FLOAT |
|
Forces output image to be tiled; for use with TIFF only. (See Section D.3.10.) |
No arguments |
|
Scales an image on the X-axis by a given factor (default is 1); image is non-uniformly scaled; may be combined only with the yScale operator; may not be combined with any other scale operators. (See Section D.3.9.4.)Foot 11 |
positive FLOAT |
|
Scales the image on theY-axis scale by a given factor (default is 1); non-uniformly scales image; may only be combined with the xScale operator; may not be combined with any other scale operators. (See Section D.3.9.5.)Foot 12 |
positive FLOAT |
Footnote 1 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Footnote 2 Specifies the percent contrast enhancement to be applied to all bands (GRAY or RGB)
Footnote 3 Specifies the percent contrast enhancement to be applied to each band (RGB only)
Footnote 4 Specifies the bounds for contrast enhancement to be applied to all bands (GRAY or RGB)
Footnote 5 Specifies the bounds for contrast enhancement to be applied to each band (RGB only)
Footnote 6 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Footnote 7 Specifies a gamma value to be applied to all bands (GRAY or RGB)
Footnote 8 Specifies separate gamma values to be applied to each band (RGB only)
Footnote 9 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Footnote 10 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Footnote 11 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Footnote 12 Enclose floating-point arguments with double quotation marks to ensure correct Globalization Support interpretation.
Note:
To ensure that floating-point values are interpreted according to the NLS_TERRITORY setting for the session, surround the value with double quotation marks (""
). For example, use 'scale="0.7"'
in the AMERICAN territory, and 'scale="0,7"'
in the FRENCH territory.Table 5-2 shows additional changes that can be made only to raw pixel and foreign images.
Table 5-2 Additional Image Processing Operators for Raw Pixel and Foreign Images
Operator Name | Usage | Values |
---|---|---|
Indicates the relative position of the red, green, and blue channels (bands) within the image; changes order of output channels. Only for RPIX. (See Section D.4.1.) |
RGB (default), RBG, GRB, GBR, BRG, BGR |
|
For multiband images, specifies either one (grayscale) or three integers indicating which channels to assign to red (first), green (second), and blue (third). Note that this operator affects the source image, not the destination; RPIX only. (See Section D.4.4.) |
positive INTEGER,Foot 1 positive INTEGER INTEGER INTEGERFoot 2 |
|
Forces pixel direction. If NORMAL, then the leftmost pixel appears first in the image. RPIX only. (See Section D.4.2.) |
NORMAL (default), REVERSE |
|
Forces scanline direction. If NORMAL, then the top scanline appears first in the image. RPIX and BMPF only. (See Section D.4.3.) |
NORMAL (default), INVERSE |
Footnote 1 Specifies that a single band is to be selected from the input image and that band will be used to create a grayscale output image
Footnote 2 Specifies that three bands are to be selected from the input image and those bands will specify the red, green, and blue bands of an RGB output image
See Appendix D for more information about process( ) method operators.
Pragmas
None.
Exceptions
ORDImageExceptions.DATA_NOT_LOCAL
This exception is raised if you call the process( ) method and the data is not local (the source.local attribute is 0).
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
Example 1:
Change the file format of image1 to GIFF:
DECLARE obj ORDSYS.ORDImage; BEGIN SELECT product_photo INTO obj FROM pm.online_media WHERE product_id = 3515 FOR UPDATE; obj.process('fileFormat=GIFF'); -- Update UPDATE pm.online_media SET product_photo = obj WHERE product_id = 3515; -- Roll back to keep original format of image: ROLLBACK; EXCEPTION WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); END; /
Example 2:
Change image1 to use a compression format of JPEG with MAXCOMPRATIO and double the length of the image along the X-axis:
DECLARE obj ORDSYS.ORDImage; BEGIN SELECT product_photo INTO obj FROM pm.online_media WHERE product_id = 3515 FOR UPDATE; obj.process( 'compressionFormat=JPEG,compressionQuality=MAXCOMPRATIO, xScale="2.0"'); -- Update: UPDATE pm.online_media SET product_photo = obj WHERE product_id = 3515; -- Roll back to keep original format of image: ROLLBACK; EXCEPTION WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); END; /
Note:
Changing the length on only one axis (for example, xScale=2.0) does not affect the length on the other axis, and would result in image distortion. Also, only the xScale and yScale parameters can be combined in a single scale operation. Any other combinations of scale operators result in an error.Example 3:
Create a thumbnail image:
The maxScale and fixedScale operators are especially useful for creating thumbnail images from various-sized originals. The following example creates, at most, a 32-by-32 pixel thumbnail image, preserving the original aspect ratio.
DECLARE obj ORDSYS.ORDImage; BEGIN SELECT product_photo INTO obj FROM pm.online_media WHERE product_id = 3515 FOR UPDATE; obj.process('maxScale=32 32'); UPDATE pm.online_media p SET product_thumbnail = obj WHERE product_id = 3515; COMMIT; EXCEPTION WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); END; /
Example 4:
Change the format to TIFF and the content format to 8BIT, BIP pixel layout, LUT interpretation, and RGB color space:
DECLARE obj ORDSYS.ORDImage; BEGIN SELECT product_photo INTO obj FROM pm.online_media WHERE product_id = 3515 FOR UPDATE; obj.process('fileFormat=TIFF, contentFormat=8BITBIPLUTRGB'); UPDATE pm.online_media SET product_photo = obj WHERE product_id = 3515; -- Roll back to keep original format of image: ROLLBACK; EXCEPTION WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); END; /
Format
processCopy(command IN VARCHAR2,
dest IN OUT ORDImage);
Description
Copies an image stored internally or externally to another image stored internally in the source.LocalData attribute (of the embedded ORDSource object) and performs one or more image processing operations on the copy.
Parameters
A list of image processing changes to make for the image in the new copy.
The destination of the new image.
Usage Notes
You cannot specify the same ORDImage as both the source and destination.
Calling this method processes the image into the destination BLOB from any source (local or external).
Implicit setProperties( ), setUpdateTime( ), and setMimeType( ) methods are applied on the destination image after the processCopy( ) method is called.
See process( ), specifically Table 5-1 and Table 5-2, for information about image processing operators.
See Appendix D for more information about processCopy( ) method operators.
Pragmas
None.
Exceptions
ORDImageExceptions.DATA_NOT_LOCAL
This exception is raised if you call the processCopy( ) method and the destination image source.local attribute value is 0 or the destination source.localData attribute is not initialized.
ORDImageExceptions.NULL_DESTINATION
This exception is raised if you call the processCopy( ) method and the destination image is NULL.
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised if you call the processCopy( ) method and the destination image source.localData attribute value is NULL. This exception is also raised if you call the processCopy( ) method and the source image source.local attribute value is 1 or NULL, and the source.localData attribute value is NULL.
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
Generate a thumbnail image from a source image:
DECLARE obj_1 ORDSYS.ORDImage; obj_2 ORDSYS.ORDImage; BEGIN SELECT product_photo, product_thumbnail INTO obj_1, obj_2 FROM pm.online_media WHERE product_id = 3515 FOR UPDATE; obj_1.processCopy('maxScale=32 32', obj_2); UPDATE pm.online_media SET product_thumbnail = obj_2 WHERE product_id=3515; COMMIT; EXCEPTION WHEN ORDSYS.ORDImageExceptions.NULL_DESTINATION THEN DBMS_OUTPUT.PUT_LINE('The destination is null'); WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); WHEN ORDSYS.ORDImageExceptions.NULL_LOCAL_DATA THEN DBMS_OUTPUT.PUT_LINE('dest.source.localData attribute is null'); COMMIT; END; /
Format
putMetadata(xmlData IN NOCOPY XMLType, metadataType IN VARCHAR2 DEFAULT 'XMP' encoding IN VARCHAR2 DEFAULT 'UTF-8');
Description
Accepts a schema valid XML document and creates a binary packet suitable for embedding in the target image file format. The packet is encoded according to the value of the encoding parameter. If the value of the metadataType parameter is XMP, a new XMP packet is written to the image, replacing any existing XMP packets.
Parameters
The XMLType that contains a schema valid XML document for the indicated metadataType. If the value of the metadataType parameter is XMP, the root element should contain a well-formed RDF document.
A string that specifies the type of metadata to write. The valid value is XMP; it is also the default.
The character encoding to be used in the image file. Valid values are UTF-8, UTF-16, UTF-16BE, and UTF-16LE. The default is UTF-8.
Usage Notes
The binary metadata packet generated from the same xmlData input may have different sizes for different encodings. Different image file formats support different encodings, and may restrict the binary metadata packet size. The following are the restrictions of the supported image formats:
GIF89a supports UTF-8 encoding only.
JPEG requires a binary packet size of less than 65502 bytes.
TIFF requires a binary packet size of less than 4 gigabytes.
See Oracle Multimedia User's Guide for more information about the metadata feature.
Pragmas
None.
Exceptions
ORDImageExceptions.DATA_NOT_LOCAL
This exception is raised when the data is not local (the source.local attribute is 0.)
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised when source.localData is NULL.
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
DECLARE image ORDSYS.ORDImage; xmlData XMLType; BEGIN SELECT product_photo INTO image FROM pm.online_media WHERE product_id = 3106 FOR UPDATE; xmlData := xmltype( '<xmpMetadata xmlns="http://xmlns.oracle.com/ord/meta/xmp">' || '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' || ' xmlns:dc="http://purl.org/dc/elements/1.1/">' || '<dc:rights>' || ' <rdf:Alt>' || ' <rdf:li xml:lang="en-us">' || ' Oracle Corporation' || ' </rdf:li>' || ' </rdf:Alt>'|| '</dc:rights>' || '</rdf:RDF>' || '</xmpMetadata>', 'http://xmlns.oracle.com/ord/meta/xmp'); image.putMetadata(xmlData, 'xmp', 'utf-8'); UPDATE pm.online_media SET product_photo = image WHERE product_id=3106; COMMIT; EXCEPTION WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN DBMS_OUTPUT.PUT_LINE('Data is not local'); WHEN ORDSYS.ORDImageExceptions.NULL_LOCAL_DATA THEN DBMS_OUTPUT.PUT_LINE('source.localData attribute is null'); WHEN ORDSYS.ORDImageExceptions.NULL_SOURCE THEN DBMS_OUTPUT.PUT_LINE('source is null'); WHEN OTHERS THEN RAISE; END;/
Format
setProperties( );
Description
Reads the image data to get the values of the object attributes, then stores them into the appropriate attribute fields. The image data can be stored in the database the source.localData attribute, or externally in a BFILE or URL. If the data is stored externally in anything other than a BFILE, the data is read into a temporary BLOB in order to determine the image characteristics.
This method should not be called for foreign images. Use the setProperties( ) for foreign images method instead.
Parameters
None.
Usage Notes
After you have copied, stored, or processed a native format image, call this method to set the current characteristics of the new content, except when this method is called implicitly.
This method sets the following information about an image:
Height in pixels
Width in pixels
Data size of the image on disk, in bytes
File type (TIFF, JFIF, and so forth)
Image type (monochrome and so forth)
Compression type (JPEG, LZW, and so forth)
MIME type (generated based on file format)
Calling this method implicitly calls the setUpdateTime( ) and the setMimeType( ) methods.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised if you call the setProperties( ) method and the source.local attribute value is 1 or NULL and the source.localData attribute value is NULL.
ORDImageExceptions.NULL_SOURCE
This exception is raised when the value of the ORDImage.source attribute is NULL.
See Appendix H for more information about these exceptions.
Examples
Select the image, and then set the attributes using the setProperties( ) method:
DECLARE image ORDSYS.ORDImage; BEGIN SELECT p.product_photo INTO image FROM pm.online_media p WHERE p.product_id = 3515 FOR UPDATE; -- set property attributes for the image data image.setProperties(); DBMS_OUTPUT.PUT_LINE('image width = ' || image.getWidth()); DBMS_OUTPUT.PUT_LINE('image height = ' || image.getHeight()); DBMS_OUTPUT.PUT_LINE('image size = ' || image.getContentLength()); DBMS_OUTPUT.PUT_LINE('image file type = ' || image.getFileFormat()); DBMS_OUTPUT.PUT_LINE('image type = ' || image.getContentFormat()); DBMS_OUTPUT.PUT_LINE('image compression = ' || image.getCompressionFormat()); DBMS_OUTPUT.PUT_LINE('image mime type = ' || image.getMimeType()); UPDATE pm.online_media p SET p.product_photo = image WHERE p.product_id = 3515; COMMIT; END; /
Format
setProperties(description IN VARCHAR2);
Description
Lets you write the characteristics of certain foreign images whose format is not natively understood by Oracle Multimedia into the appropriate attribute fields.
Parameters
The image characteristics to set for the foreign image.
Usage Notes
Note:
Once you have set the properties for a foreign image, it is up to you to keep the properties consistent. If Oracle Multimedia detects an unknown file format, it will not implicitly set the properties.See Appendix E for information about when to use foreign image support. Only some formats that are not natively understood can be described using this setProperties( ) method.
After you have copied, stored, or processed a foreign image, call this method to set the characteristics of the new image content. Unlike the native image types described in Appendix B, foreign images either do not contain information about how to interpret the bits in the file or, Oracle Multimedia does not understand the information. In this case, you must set the information explicitly.
You can set the image characteristics for foreign images as described inTable 5-3.
Table 5-3 Image Characteristics for Foreign Files
Field | Data Type | Description |
---|---|---|
CompressionFormat |
STRING |
Specifies the compression format value. Valid values are: CCITTG3, CCITTG4, or NONE (default). |
DataOffset |
INTEGER |
Specifies an offset (from the beginning of the file to the start of the image data) that Oracle Multimedia does not try to interpret. Set the offset to skip any potential header. The value must be a nonnegative integer less than the LOB length. Default is zero. |
DefaultChannelSelection |
INTEGER or INTEGER, INTEGER, INTEGER |
Specifies which bands in a multiband image will be interpreted as color channels when the image is read or processed. If a single integer is specified, the image will be treated as a grayscale image consisting of the data in the specified band only. If three integers are specified, the image will be treated as an RGB image, using the first specified band as the red channel, the second as the green channel, and the third as the blue channel. The first band in the image is numbered 1. The band specifications must be equal to or lower than the number of bands in the image. For example:
|
Height |
INTEGER |
Specifies the height of the image in pixels. Value must be a positive integer. There is no default, thus a value must be specified. |
Interleaving |
STRING |
Specifies the band layout within the image. Valid styles are:
|
NumberOfBands |
INTEGER |
Specifies the number of color bands in the image with a value that is a positive integer less than 255. Default is 3. |
PixelOrder |
STRING |
Specifies a string to indicate the pixel order. If the string is NORMAL (default), the leftmost pixel appears first in the file. If the string is REVERSE, the rightmost pixel appears first. |
ScanlineOrder |
STRING |
Specifies a string to indicate the scanline order. If the string is NORMAL (default), the top scanline appears first in the file. If the string is INVERSE, then the bottom scanline appears first. |
UserString |
STRING |
Specifies a 4-character descriptive string. If used, the string is stored in the fileFormat attribute, appended to the user string " OTHER:". Default is blank and fileFormat is set to "OTHER". |
Width |
INTEGER |
Specifies the width of the image in pixels. Value must be a positive integer. There is no default, thus a value must be specified. |
MimeType |
STRING |
Specifies a MIME type, such as img/gif. |
The values supplied to the setProperties( ) for foreign images method are written to the existing ORDImage data attributes. The fileFormat attribute is set to OTHER and includes the user string, if supplied; for example, OTHER: LANDSAT.
Pragmas
None.
Exceptions
ORDImageExceptions.NULL_PROPERTIES_DESCRIPTION
This exception is raised if you call the setProperties( ) for foreign images method and the description parameter value is NULL.
See Appendix H for more information about this exception.
Examples
Select the foreign image, and then set the properties for the image:
DECLARE obj ORDSYS.ORDImage; BEGIN SELECT p.product_photo INTO obj FROM pm.online_media p WHERE p.product_id = 3501 FOR UPDATE; -- Set property attributes for the image data: obj.setProperties('width=123 height=321 compressionFormat=NONE' || ' userString= LANDSTAT dataOffset=128' || ' scanlineOrder=INVERSE pixelOrder=REVERSE' || ' interleaving=BIL numberOfBands=1' || ' defaultChannelSelection=1'); UPDATE pm.online_media SET product_photo = obj WHERE product_id=3501; COMMIT; END; /