Oracle® Multimedia Reference 11g Release 2 (11.2) Part Number E10776-01 |
|
|
View PDF |
Oracle Multimedia describes the ORDImage object type, which supports the storage, management, and manipulation of image data.
The ORDImage object type is defined in the ordispec.sql
file. After installation, this file is available in the Oracle home directory at:
<ORACLE_HOME>
/ord/im/admin
(on Linux and UNIX)
<ORACLE_HOME>
\ord\im\admin
(on Windows)
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 (PM) sample schema. To replicate the examples on your computer, begin with the examples shown in the reference pages for the ORDImage constructors and the import( ) and importFrom( ) methods. Substitute your image files for those in the examples.
See Oracle Database Sample Schemas for information about the Product Media sample schema.
The example for the constructor ORDImage for BLOBs uses the test image table TIMG (see TIMG Table Definition).
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.Directory Definition
Issue the following statements before executing the examples, where c:\mydir\work
is the directory where the user ron
can find the image data:
CONNECT sys as sysdba CREATE OR REPLACE DIRECTORY FILE_DIR as 'c:\mydir\work'; GRANT READ ON DIRECTORY FILE_DIR TO 'ron';
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 must 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 must 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 use the ctx argument, but if you code as previously described, your application should work with current or future source or format plug-ins.For formats that are natively supported, use the setProperties( ) method to automatically populate the attributes of the object. Otherwise, use the setProperties( ) method for foreign images; or use any of the individual set methods to set the attribute value for an object for formats that are not natively supported.
The ORDImage object type supports the storage, management, and manipulation of image data. The attributes for this object type are defined as follows in the ordispec.sql
file:
------------------- -- TYPE ATTRIBUTES ------------------- source ORDSource, height INTEGER, width INTEGER, contentLength INTEGER, fileFormat VARCHAR2(4000), contentFormat VARCHAR2(4000), compressionFormat VARCHAR2(4000), mimeType VARCHAR2(4000),
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, JFIF, and so on).
contentFormat: the type of image (monochrome and so on).
compressionFormat: the compression algorithm used on the image data.
mimeType: the MIME type information.
This section describes these ORDImage constructor functions:
Format
ORDImage(SELF IN OUT NOCOPY ORDSYS.ORDImage, data IN BLOB, setproperties IN INTEGER DEFAULT 0) RETURN SELF AS RESULT
Description
Constructs an ORDImage object from a BLOB. The data stored in the BLOB is copied into the ORDImage object when the constructed ORDImage object is inserted or updated into a table.
Parameters
Image content stored in a BLOB.
Indicator flag that determines whether the setProperties( ) method is called in the constructor. If the value is 1
, the setProperties( ) method is called. If the value is 0
, the method is not called. The default is 0
.
Pragmas
None.
Exceptions
None.
Usage Notes
Use this constructor to create an ORDImage object when the image content is stored in either a temporary or a persistent BLOB.
Examples
Create an ORDImage object from a BLOB object and insert it into the table.
Note:
The user who runs this statement must have the SELECT privilege on the tabletimg
created by the user mediauser
.
See Section 7.1.4 for a definition of the test image table TIMG.
INSERT INTO pm.online_media (product_id, product_photo) SELECT 3501, ORDSYS.ORDImage(t.img) FROM mediauser.timg t WHERE t.n = 1;
Format
ORDImage( SELF IN OUT NOCOPY ORDSYS.ORDImage, source_type IN VARCHAR2 DEFAULT 'LOCAL', source_location IN VARCHAR2 DEFAULT NULL, source_name IN VARCHAR2 DEFAULT NULL, setproperties IN INTEGER DEFAULT 0 ) RETURN SELF AS RESULT
Description
Constructs an ORDImage object from a specific source. By default, an empty object with a local source is constructed.
Parameters
The type of the source image data. Valid values are: FILE
, HTTP
, or LOCAL
. The default is LOCAL
. (See Table 2-1.)
The location from which the source image data is to be imported. (See Table 2-2.)
The name of the source image data. (See Table 2-3.)
Indicator flag that determines whether the setProperties( ) method is called in the constructor. If the value is 1
, the setProperties( ) method is called. If the value is 0
, the method is not called. The default is 0
.
Pragmas
None.
Exceptions
None.
Usage Notes
Use this constructor to create an ORDImage object when the image content is not stored in a BLOB, as in any of these situations:
Examples
Create an ORDImage object from a specified source:
-- Construct an ORDImage object from an external file and insert it into the table. INSERT INTO pm.online_media (product_id, product_photo) VALUES (3515, ORDSYS.ORDImage('FILE', 'FILE_DIR', 'speaker.jpg')); -- Initialize an ORDImage object in the table. INSERT INTO pm.online_media (product_id, product_photo) VALUES(3501, ORDSYS.ORDImage());
This section presents reference information about the Oracle Multimedia methods used specifically for image data manipulation.
Chapter 2 presents reference information about 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.
For more information about object types and methods, see Oracle Database Concepts.
This section describes these methods:
Format
applyWatermark(SELF IN OUT NOCOPY ORDImage, added_image IN OUT NOCOPY ORDImage, dest IN OUT NOCOPY ORDImage, logging OUT VARCHAR2, watermark_properties IN ORDSYS.ORD_STR_LIST default null),
Description
Overlays an image watermark onto a source image and writes it to a destination image object.
Parameters
The watermark image stored in an ORDImage object to be added to the source image.
The destination ORDImage object for the watermarked image.
A string that contains information about any unexpected behavior that occurred during the watermarking operation. If the operation is successful, an empty string is returned.
A string list of name-value pairs that define the attributes of the watermark image to be overlaid, including: width
, height
, position
, position_x
, position_y
, and transparency
. See Table D-1 for the complete list of watermark properties.
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).
See Section D.6 for more information about watermarking operations and watermark properties.
Pragmas
None.
Exceptions
ORDImageExceptions.DATA_NOT_LOCAL
This exception is raised if you call the applyWatermark( ) 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 applyWatermark( ) method and the destination image is NULL.
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised if you call the applyWatermark( ) method and the destination image source.localData attribute value is NULL. This exception is also raised if you call the applyWatermark( ) 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 if the source or watermark image source attribute value is NULL.
See Appendix G for more information about these exceptions.
Examples
Add a watermark image to a source image:
-- add image as watermark to source image DECLARE source_image ORDSYS.ORDImage; added_image ORDSYS.ORDImage; dest_image ORDSYS.ORDImage; prop ordsys.ord_str_list; logging VARCHAR2(2000); BEGIN select product_photo into source_image from pm.online_media where product_id = 4001; select product_photo into added_image from pm.online_media where product_id = 4002; select product_photo into dest_image from pm.online_media where product_id = 4003 for update; -- specify properties prop := ordsys.ord_str_list( 'position=bottomright', 'transparency=0.2'); -- add image watermark to source image source_image.applyWatermark(added_image, dest_image, logging, prop); update pm.online_media set product_photo = dest_image where product_id = 4003; commit; EXCEPTION WHEN OTHERS THEN RAISE; END; /
where:
product_id 4001
: the source image (in JPEG format) stored in the table. The source image is larger than the watermark image.
product_id 4002
: the watermark image (in PNG format) stored in the table. The watermark image is overlaid onto the bottom right position of the source image.
product_id 4003
: the resulting watermarked image stored in the table.
Format
applyWatermark(SELF IN OUT NOCOPY ORDImage, added_text IN VARCHAR2, dest IN OUT NOCOPY ORDImage, logging OUT VARCHAR2, watermark_properties IN ORDSYS.ORD_STR_LIST default null),
Description
Overlays a text watermark onto a source image and writes it to a destination image object.
Parameters
The watermark text stored in a string to be added to the source image.
The destination ORDImage object for the watermarked image.
A string that contains information about any unexpected behavior that occurred during the watermarking operation. If the operation is successful, an empty string is returned. Otherwise, this method returns a string that describes the unexpected behavior. For example: if watermark text is so long that it is truncated, this string is returned: WARNING: text is too long and truncated.
A string list of name-value pairs that define the attributes of the watermark text to be overlaid, including: font_name
, font_style
, font_size
, text_color
, position_x
, position_y
, and transparency
. See Table D-1 for the complete list of watermark properties.
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).
See Section D.6 for more information about watermarking operations and watermark properties.
Pragmas
None.
Exceptions
ORDImageExceptions.DATA_NOT_LOCAL
This exception is raised if you call the applyWatermark( ) 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 applyWatermark( ) method and the destination image is NULL.
ORDImageExceptions.NULL_LOCAL_DATA
This exception is raised if you call the applyWatermark( ) method and the destination image source.localData attribute value is NULL. This exception is also raised if you call the applyWatermark( ) 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 if the source image source attribute value is NULL.
See Appendix G for more information about these exceptions.
Examples
Add watermark text to a source image:
-- add text as watermark to source image DECLARE source_image ORDSYS.ORDImage; added_text varchar2(200); dest_image ORDSYS.ORDImage; prop ordsys.ord_str_list; logging VARCHAR2(2000); BEGIN select product_photo into source_image from pm.online_media where product_id = 4001; select product_photo into dest_image from pm.online_media where product_id = 4003 for update; added_text := 'Oracle Multimedia © 2009'; -- specify properties prop := ordsys.ord_str_list( 'font_name=Times New Roman', 'font_style=bold', 'font_size=50', 'text_color=red', 'position_x=100', 'position_y=100', 'transparency=0.6'); -- add text watermark to source image source_image.applyWatermark(added_text, dest_image, logging, prop); update pm.online_media set product_photo = dest_image where product_id = 4003; commit; EXCEPTION WHEN OTHERS THEN RAISE; END; /
where:
product_id 4001
: the source image (in JPEG format) stored in the table.
product_id 4003
: the resulting watermarked image stored in the table.
Format
checkProperties( ) RETURN BOOLEAN;
Description
Verifies that the properties stored in attributes of the image object match the properties of the image. Do not use this method 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 G 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 the source data is stored locally or not.
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 G 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
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 two or more types of supported metadata are 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. Use the XQuery function fn:namespace-uri
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.
See Oracle XML DB Developer's Guide for more information about XQuery functions.
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 G for more information about these exceptions.
Examples
DECLARE image ORDSYS.ORDImage; metav XMLSequenceType; ns varchar2(4000); 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 select xmlcast(xmlquery('fn:namespace-uri($x)' passing metav(i) as "x" returning content) as varchar2(4000)) into ns from dual; DBMS_OUTPUT.PUT_LINE('namespace: ' || ns); 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 parameter must 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 before 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 must 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 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 G 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 parameter must 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 must 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 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 G 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 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 FLOATFootref 2, nonnegative FLOAT FLOAT FLOAT FLOAT FLOAT FLOATFoot 4 |
|
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); cannot be combined with other scale operators. (See Section D.3.10.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.)Footref 1 |
||
Scales an image to a specified size in pixels (width, height), while maintaining the aspect ratio; cannot be combined with other scale operators. (See Section D.3.10.2.) |
positive INTEGER INTEGER |
|
Places columns of an image in reverse order -- swapped left to right. (See Section D.3.5.) |
No arguments |
|
Processes an image without encoding the image's metadata in the resulting image. (See Section D.3.6.) |
No arguments |
|
Selects a page from a multipage file; for use with TIFF only; first page is 0 (zero). (See Section D.3.7.) |
nonnegative INTEGER |
|
Specifies how image quantization is to be performed when reducing image bit depth. (See Section D.3.8.) |
ERRORDIFFUSION (default), ORDEREDDITHER, THRESHOLD, MEDIANCUT |
|
Rotates an image within the image plane by the angle specified. (See Section D.3.9.)Footref 1 |
FLOAT |
|
Uniformly scales an image by a given factor (for example, 0 .5 or 2.0); cannot be combined with other scale operators. (See Section D.3.10.3.)Footref 1 |
positive FLOAT |
|
Sharpens an image by a given kernel type and gain factor (for example, 0 and 2.0); can be combined with scale operators. (See Section D.3.11.)Footref 1 |
positive INTEGER positive FLOAT |
|
Forces output image to be tiled; for use with TIFF only. (See Section D.3.12.) |
No arguments |
|
Fills the transparent regions of PNG image file formats with color. (See Section D.3.13.) |
BLACK, BLUE, CYAN, DARK_GRAY, GRAY, GREEN, LIGHT_GRAY MAGENTA, ORANGE, PINK, RED, WHITE, YELLOW, or a nonnegative INTEGER INTEGER INTEGER |
|
Scales an image on the X-axis by a given factor (default is 1); image is non-uniformly scaled; can be combined with the yScale operator only; cannot be combined with any other scale operators. (See Section D.3.10.4.)Footref 1 |
positive FLOAT |
|
Scales the image on theY-axis scale by a given factor (default is 1); non-uniformly scales image; can be combined with the xScale operator only; cannot be combined with any other scale operators. (See Section D.3.10.5.)Footref 1 |
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 each band (RGB only)
Footnote 5 Specifies separate gamma values to be applied to each band (RGB only)
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). 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 is to 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 are to 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 G 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 if the value of the source attribute for the source image is NULL.
See Appendix G 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, this method writes a new XMP packet 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 restrictions of the supported image formats are as follows:
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 G 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 so as to determine the image characteristics.
Do not call this method 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, unless this method is called implicitly.
This method sets this 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 on)
Image type (monochrome and so on)
Compression type (JPEG, LZW, and so on)
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 G 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 does 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 are interpreted as color channels when the image is read or processed. If a single integer is specified, the image is treated as a grayscale image consisting of the data in the specified band only. If three integers are specified, the image is 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 G 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; /