Oracle8i interMedia Audio, Image, and Video User's Guide and Reference Release 8.1.5 A67299-01 |
|
Oracle8i interMedia contains the following information about the ORDImage type:
The examples in this chapter assume that the test image tables EMP and OLD_IMAGE have been created and filled with data. These tables were created using the SQL statements described in Section 4.2.1.
Methods invoked at the ORDSource level that are handed off to the source plug-in for processing have ctx (RAW(4000)) 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 source.open( ) method. At this point, the source plug-in can initialize the context for this client. When processing is complete, the client should invoke the source.close( ) method.
Methods invoked from a source plug-in call have the first argument as ctx (RAW(4000)).
Oracle8i interMedia describes the ORDImage object type, which supports the storage, management, and manipulation of image data.
The ORDImage object type supports the storage and management of image data. This object type is defined as follows:
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 ----------------------- Methods associated with copy operations
MEMBER PROCEDURE copy(dest IN OUT ORDImage),-- Methods associated with image process 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 getContentLength RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getContentLength, 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 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 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 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),-- Methods associated with image migration
MEMBER PROCEDURE migrateFromORDImgB(old_object ORDImgB), MEMBER PROCEDURE migrateFromORDImgF(old_object ORDImgF) );
where:
This section presents reference information on the Oracle8i interMedia methods used for image data manipulation. These methods are described in the following groupings:
Note: Sources natively supported by interMedia are not writable and therefore do not support the export method. User-defined sources may support the export method. |
The methods described in this chapter show examples based on a test image table EMP. Refer to the EMP table definition that follows when reading through the examples in Section 4.2.2 through Section 4.2.9:
CREATE TABLE emp ( ename VARCHAR2(50), salary NUMBER, job VARCHAR2(50), department INTEGER, photo ORDSYS.ORDImage, large_photo ORDSYS.ORDImage); DECLARE Image ORDSYS.ORDImage; BEGIN INSERT INTO emp VALUES ('John Doe', 24000, 'Technical Writer', 123, ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(),'file','ORDIMGDIR', 'jdoe.gif',SYSDATE,0), NULL,NULL,NULL,NULL,NULL,NULL,NULL), ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(),'file','ORDIMGDIR', 'jdoe.gif',SYSDATE,0), NULL,NULL,NULL,NULL,NULL,NULL,NULL)); SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; Image.setProperties; UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; COMMIT; END; /
Refer to the EMP and OLD_IMAGES table definitions that follow when reading through the examples in Section 4.2.10.
CREATE TABLE emp ( ename VARCHAR2(50), salary NUMBER, job VARCHAR2(50), department INTEGER, large_photo ORDSYS.ORDImage); CREATE TABLE old_images ( id NUMBER, imageb ORDSYS.ORDIMGB, imagef ORDSYS.ORDIMGF); DECLARE blobimage ORDSYS.ORDIMGB; bfileimage ORDSYS.ORDIMGF; BEGIN INSERT INTO old_images values (1, ORDSYS.ORDIMGB(empty_blob(),NULL,NULL,NULL,NULL,NULL,NULL), ORDSYS.ORDIMGF(bfilename('ORDIMGDIR','jdoe.gif'), NULL,NULL,NULL,NULL,NULL,NULL)); SELECT imageb, imagef INTO blobimage, bfileimage FROM old_images WHERE id = 1 FOR UPDATE; bfileimage.copyContent(blobimage.content); blobimage.setProperties; bfileimage.setProperties; UPDATE old_images SET imageb=blobimage, imagef=bfileimage WHERE id = 1; INSERT INTO emp values ( 'John Doe', 24000, 'Technical Writer', 123, ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(),NULL,NULL,NULL, SYSDATE,1), NULL,NULL,NULL,NULL,NULL,NULL,NULL)); COMMIT; end; /
This section presents reference information on the ORDImage method associated with the copy operation.
copy(dest IN OUT ORDImage);
Copies an image without changing it.
The destination of the new image.
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 timestamp information.
none
If the destination source.localData attribute is not initialized, calling this method raises a NULL_LOCAL_DATA exception.
If the source.isLocal attribute value is 1 and the source.localData attribute value is NULL, calling this method raises a NULL_LOCAL_DATA exception.
Create a copy of the image:
DECLARE Image_1 ORDSYS.ORDImage; Image_2 ORDSYS.ORDImage; BEGIN SELECT photo, large_photo INTO Image_2, Image_1 FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- copy the data from Image_1 to Image_2 Image_1.copy(Image_2); UPDATE emp SET photo = Image_2 WHERE ename = 'John Doe'; END; /
This section presents reference information on the ORDImage methods associated with the process operation.
process(command IN VARCHAR2);
Performs one or more image processing operations on a BLOB, writing the image back on to itself.
A list of image processing operations to perform on the image.
You can change one or more of the image attributes shown in Table 4-1. Table 4-2 shows additional changes that can be made only to raw pixel and foreign images.
There is no implicit import( ) or importFrom( ) call performed when you call this method; if data is external, you must first call import( ) or importFrom( ) to make the data local before you can process it.
Implicit setProperties( ), setUpdateTime( ), and setMimeType( ) methods are done after the process( ) method is called.
See Appendix C for more information on process( ) method operators.
none
If data is not local or the source.localData attribute is not initialized, calling this method raises a DATA_NOT_LOCAL exception.
Change the file format of image1 to GIF:
image1.process('fileFormat=GIFF');
Change image1 to use lower quality JPEG compression and double the length of the image along the X-axis:
image1.process('compressionFormat=JPEG, compressionQuality=MAXCOMPRATIO, xScale="2.0"');
Note that 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 operation. Any other combinations of scale operators result in an error.
The maxScale and fixedScale operators are especially useful for creating thumbnail images from various-sized originals. The following line creates at most a 32-by-32 pixel thumbnail image, preserving the original aspect ratio:
image1.process(maxScale="32 32");
Convert the image to TIFF:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; Image.process('fileFormat=TIFF'); UPDATE emp SET photo = Image WHERE ename = 'John Doe'; END; /
processCopy(command IN VARCHAR2, dest IN OUT ORDImage);
Copies an image stored internally or externally to another image stored internally in a BLOB.
A list of image processing changes to make for the image in the new copy.
The destination of the new image.
See Table 4-1, "Image Processing Operators" and Table 4-2, "Additional Image Processing Operators for Raw Pixel and Foreign Images".
You cannot specify the same BLOB 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 done on the destination image after the processCopy( ) method is called.
See Appendix C for more information on processCopy operators.
none
If the value of dest is NULL, calling this method raises a NULL_DESTINATION exception.
If the dest.source.isLocal attribute value is FALSE, (the destination image must be local), calling this method raises a DATA_NOT_LOCAL exception.
If the dest.source.localData attribute value is NULL (destination image must be initialized), then calling this method raises a NULL_LOCAL_DATA exception.
If the source.isLocal attribute value is 1 and the source.localData attribute value is NULL, calling this method raises a NULL_LOCAL_DATA exception.
Copy an image, changing the file format, compression format, and data format in the destination image:
DECLARE Image_1 ORDSYS.ORDImage; Image_2 ORDSYS.ORDImage; mycommand VARCHAR2(400); BEGIN SELECT photo, large_photo INTO Image_2, Image_1 FROM emp WHERE ename = 'John Doe' FOR UPDATE; mycommand := 'fileFormat=tiff compressionFormat=packbits contentFormat = 8bitlut'; Image_1.processCopy(mycommand, Image_2); UPDATE emp SET photo = Image_2 WHERE ename = 'John Doe'; END; /
This section presents reference information on the ORDImage methods associated with the properties set and check operations.
setProperties;
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 in a BLOB, 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(description) method for foreign images.
none
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:
Calling this method implicitly calls the setUpdateTime( ) and the setMimeType( ) methods.
none
If the source.isLocal attribute value is 1 and the source.localData attribute value is NULL, calling this method raises a NULL_LOCAL_DATA exception.
Select the image, and then set the attributes using the setProperties method:
DECLARE Image ORDSYS.ORDImage; BEGIN INSERT INTO emp VALUES ('John Doe', 24000, 'Technical Writer', 123, ORDSYS.ORDImage(ORDSYS.ORDSource(empty_blob(),'file','ORDIMGDIR', 'jdoe.gif',SYSDATE,0), NULL,NULL,NULL,NULL,NULL,NULL,NULL)); -- select the newly inserted row for update SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' 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 emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
Example output:
image width = 360 image height = 490 image size = 66318 image file type = JFIF image type = 24BITRGB image compression = JPEG image mime type = image/jpeg
setProperties(description IN VARCHAR2);
Allows you to write the characteristics of a foreign image into the appropriate attribute fields.
Specifies the image characteristics to set for the foreign image.
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 D, foreign (or headerless) images either do not contain information on how to interpret the bits in the file or, interMedia image does not understand the information. In this case, you must set the information explicitly.
You can set the following image characteristics for foreign images, as shown in Table 4-3.
The values supplied to setProperties( ) are written to the existing ORDImage data attributes. The fileFormat is set to "OTHER" and includes the user string, if supplied; for example, 'OTHER: LANDSAT'.
none
If the description attribute value is NULL, calling this method raises a NULL_PROPERTIES_DESCRIPTION exception.
Select the foreign image and then set the properties for the image:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- set property attributes for the image data Image.setProperties('width=123 height=321 compressionFormat=NONE' || ' userString=DJM dataOffset=128' || ' scanlineOrder=INVERSE pixelOrder=REVERSE' || ' interleaving=BIL numberOfBands=1' || ' defaultChannelSelection=1'); UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
checkProperties RETURN BOOLEAN;
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.
none
Use this method to verify that the image attributes match the actual image.
none
none
Check the image attributes:
DECLARE Image ORDSYS.ORDImage; properties_match BOOLEAN; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- check that properties match the image properties_match := Image.checkProperties; IF properties_match THEN DBMS_OUTPUT.PUT_LINE('Check Properties succeeded'); END IF; END; /
This section presents reference information on the ORDImage methods associated with the image attributes.
getHeight RETURN INTEGER;
Returns the height of an image in pixels. This method does not actually read the image; it is a simple accessor method that returns the value of the height attribute.
none
Use this method rather than accessing the height attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getHeight, WNDS, WNPS, RNDS, RNPS)
none
Get the height of an image:
DECLARE Image ORDSYS.ORDImage; Height INTEGER; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image height Height := Image.getHeight; END; /
getWidth RETURN INTEGER;
Returns the width of an image in pixels. This method does not actually read the image; it is a simple accessor method that returns the value of the width attribute.
none
Use this method rather than accessing the width attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getWidth, WNDS, WNPS, RNDS, RNPS)
none
Get the width of an image:
DECLARE Image ORDSYS.ORDImage; Width INTEGER; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image width Width := Image.getWidth; END; /
getContentLength RETURN INTEGER;
Returns the length of the image data content stored in the source. This method does not actually read the image; it is a simple access method that returns the value of the content length attribute.
none
Use this method rather than accessing the contentLength attribute directly to protect from potential future changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS, WNPS, RNDS, RNPS)
none
Get the length of the image data content stored in the source:
DECLARE Image ORDSYS.ORDImage; ContentLength INTEGER; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image size ContentLength := Image.getContentLength; END;
getFileFormat RETURN VARCHAR2;
Returns the file type of an image (such as TIFF or JFIF). This method does not actually read the image; it is a simple accessor method that returns the value of the fileFormat attribute.
none
Use this method rather than accessing the fileFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getFileFormat, WNDS, WNPS, RNDS, RNPS)
none
Get the file type of an image:
DECLARE Image ORDSYS.ORDImage; FileFormat VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image file format FileFormat := Image.getFileFormat; END;
getContentFormat RETURN VARCHAR2;
Returns the content type of an image (such as monochrome or 8-bit grayscale). This method does not actually read the image; it is a simple accessor method that returns the value of the contentFormat attribute.
none
Use this method rather than accessing the contentFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getContentFormat, WNDS, WNPS, RNDS, RNPS)
none
Get the type of an image:
DECLARE Image ORDSYS.ORDImage; ContentFormat VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image content format ContentFormat := Image.getContentFormat; END;
getCompressionFormat RETURN VARCHAR2;
Returns the compression type of an image. This method does not actually read the image, it is a simple accessor method that returns the value of the compressionFormat attribute.
none
Use this method rather than accessing the compressionFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object.
PRAGMA RESTRICT_REFERENCES(getCompressionFormat, WNDS, WNPS, RNDS, RNPS)
none
Get the compression type of an image:
DECLARE Image ORDSYS.ORDImage; CompressionFormat VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image compression format CompressionFormat := Image.getCompressionFormat; END;
This section presents reference information on the ORDImage methods associated with the local attribute.
setLocal;
Sets the local attribute to indicate that the data is stored internally in a BLOB. When local is set, image methods look for image data in the source.localData attribute.
none
Sets the local attribute to 1, meaning the data is stored locally in the localData attribute.
none
If the source.localData attribute value is NULL, calling this method raises a NULL_LOCAL_DATA exception.
Set the flag to local for the data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- set local so we look for the image in the database Image.setLocal; UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
clearLocal;
Resets the local flag to indicate that the data is stored externally. When the local flag is set to clear, image methods look for image data using the srcLocation, srcName, and srcType attributes.
none
This method sets the local attribute to a 0, meaning the data is stored externally or outside of Oracle8i.
none
none
Clear the value of the local flag for the data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- clear local so we look for image externally Image.clearLocal; UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
isLocal RETURN BOOLEAN;
Returns TRUE if the data is stored locally in a BLOB or FALSE if the data is stored externally.
none
If the local attribute is set to 1 or NULL, this method returns TRUE, otherwise this method returns FALSE.
Pragma RESTRICT_REFERENCES(isLocal, WNDS, WNPS, RNDS, RNPS)
none
Determine whether or not the data is local:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- check to see if image is stored locally IF Image.isLocal THEN DBMS_OUTPUT.PUT_LINE('Image is stored locally'); ELSE DBMS_OUTPUT.PUT_LINE('Image is stored externally'); END IF; END; /
This section presents reference information on the ORDImage methods associated with the date attribute.
getUpdateTime RETURN DATE;
Returns the time when the object was last updated.
none
none
PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS, WNPS, RNDS, RNPS)
none
Get the updated time of some image object:
DECLARE Image ORDSYS.ORDImage; UpdateTime DATE; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image update time UpdateTime := Image.getUpdateTime; END; /
setUpdateTime(current_time DATE);
Sets the time when the image data was last updated. Use this method whenever you modify the image data. The methods copy( ), process( ), processCopy( ), setProperties, setMimeType( ), and export( ) call this method implicitly.
The timestamp to be stored. Default is SYSDATE.
You must invoke this method any time you modify the image data yourself.
none
none
Set the updated time of some image data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- set the image update time Image.setUpdateTime(SYSDATE); END; /
This section presents reference information on the ORDImage methods associated with the mimeType attribute.
getMimeType RETURN VARCHAR2;
Returns the MIME type for the image data. This is a simple accessor method that returns the value of the mimeType attribute.
none
Use this method rather than accessing the mimeType attribute directly to protect yourself from potential changes to the internal representation of the ORDImage object. If the source is a file or BLOB, the MIME type information is generated.
For unrecognized file formats, users must call the setMimeType( ) method and specify the MIME type.
PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS)
none
Return the MIME type:
DECLARE Image ORDSYS.ORDImage; MimeType VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image mime type MimeType := Image.getMimeType; END; /
setMimeType(mime IN VARCHAR2);
Allows you to set the MIME type of the image data.
The MIME type.
You can override the automatic setting of MIME information by calling this method with a specified MIME value.
You must call this method to set the MIME type for foreign images.
Calling this method implicitly calls the setUpdateTime( ) method.
The methods setProperties, process( ), and processCopy( ) call this method implicitly.
The MIME type is extracted from the HTTP header on import for HTTP sources.
none
none
Set the MIME type for some stored image data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- set the image mime type Image.setMimeType('image/bmp'); END;
This section presents reference information on the ORDImage methods associated with the source attribute.
getContent RETURN BLOB;
Returns a handle to the local LOB storage, that is the BLOB within the ORDImage object.
none
none
PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS)
none
A client accesses image data:
DECLARE Image ORDSYS.ORDImage; localData BLOB; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image BLOB localData := Image.getContent; END; /
getBFILE RETURN BFILE;
Returns the LOB locator of the BFILE containing the image.
none
This method constructs and returns a BFILE using the stored source.srcLocation and source.srcName attribute information. The source.srcLocation attribute must contain a defined directory object. The source.srcName attribute must be a valid file name.
PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS)
If the source.srcType attribute value is NULL, calling this method raises an INCOMPLETE_SOURCE_INFORMATION exception.
If the value of srcType is other than FILE, then calling this method raises an INVALID_SOURCE_TYPE exception.
DECLARE Image ORDSYS.ORDImage; imagebfile BFILE; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image BFILE imagebfile := Image.getBFILE; END;
deleteContent;
Deletes the local data from the current local source (localData).
none
This method can be called after you export the data from the local source to an external image data source and you no longer need this data in the local source.
Call this method when you want to update the object with a new object.
none
none
Delete the local data from the current local source:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- delete the local content of the image Image.deleteContent; UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
setSource(source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2);
Sets or alters information about the external source of the image data.
The source type of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.
The source location of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.
The source name of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.
Users can use this method to set the image data source to a new BFILE or URL. Calling this method implicitly calls the setUpdateTime( ) method.
none
none
Set the source of the image data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- set source information for the image Image.setSource('file', 'ORDIMGDIR', 'jdoe.gif'); UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
getSource RETURN VARCHAR2;
Returns information about the external location of the image data in URL format.
none
Possible return values are:
PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS)
none
Get the source of the image data:
DECLARE Image ORDSYS.ORDImage; SourceInfo VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source information SourceInfo := Image.getSource; END;
getSourceType RETURN VARCHAR2;
Returns a string containing the type of the external image data source.
none
This method returns a VARCHAR2 string containing the type of the external image data source, for example 'FILE'.
PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS)
none
Get the source type information about an image data source:
DECLARE Image ORDSYS.ORDImage; SourceType VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source type SourceType := Image.getSourceType; END; /
getSourceLocation RETURN VARCHAR2;
Returns a string containing the value of the external image data source location.
none
This method returns a VARCHAR2 string containing the value of the external image data location, for example 'BFILEDIR'.
You must ensure that the directory exists or is created before you use this method.
PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS, WNPS, RNDS, RNPS)
If the value of srcLocation is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_LOCATION exception.
Get the source location information about an image data source:
DECLARE Image ORDSYS.ORDImage; SourceLocation VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source location SourceLocation := Image.getSourceLocation; END;
getSourceName RETURN VARCHAR2;
Returns a string containing the name of the external image data source.
none
Returns a VARCHAR2 string containing the name of the external data source, for example 'testimg.dat'.
PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS, WNPS, RNDS, RNPS)
If the value of srcName is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_NAME exception.
Get the source name information about an image data source:
DECLARE Image ORDSYS.ORDImage; SourceName VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source name SourceName := Image.getSourceName; END; /
MEMBER PROCEDURE import(ctx IN OUT RAW);
Transfers image data from an external image data source to a local source (localData) within an Oracle database.
The source plug-in context information. This must be allocated. You must call the source.open( ) method; see the introduction to this chapter for more information.
Use the setSource( ) method to set the external source type, location, and name prior to calling the import( ) method.
You must ensure that the directory exists or is created before you use this method.
After importing data from an external image data source to a local source (within an 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 the setLocal methods.
If the file format of the imported image is native, the setProperties( ) method is also called.
none
If the value of srcType is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION exception.
If the value of dlob is NULL, then calling this method raises an ORDSourceExceptions.NULL_SOURCE exception.
If the import( ) method is not supported by the source plug-in being used, an ORDSourceExceptionsMETHOD_NOT_SUPPORTED exception is raised.
See Appendix H for more information about these exceptions.
Import image data from an external image data source into the local source:
DECLARE Image ORDSYS.ORDImage; ctx RAW(4000) :=NULL; BEGIN -- select the image to be imported SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- import the image into the database Image.import(ctx); -- update the image object UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
importFrom(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2);
Transfers image data from the specified external image data source to a local source (localData) within an Oracle database.
The source plug-in context information. This must be allocated. You must call the source.open( ) method; see the introduction to this chapter for more information.
The source type of the image data.
The location from where the image data is to be imported.
The name of the image data.
This method is similar to the import( ) method except the source information is specified within the method instead of separately.
You must ensure that the directory exists or is created before you use this method.
After importing data from an external image data source to a local source (within an 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 native, the setProperties( ) method is also called.
none
If the value of dlob is NULL, then calling this method raises an ORDSourceExceptions.NULL_SOURCE exception.
If the importFrom( ) method is not supported by the source plug-in being used, an ORDSourceExceptions.METHOD_NOT_SUPPORTED exception is raised.
Calling this method within a source plug-in when any other exception is raised, raises an ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION exception.
See Appendix H for more information about these exceptions.
Import image data from the specified external data source into the local source:
DECLARE Image ORDSYS.ORDImage; ctx RAW(4000) :=NULL; BEGIN -- select the image to be imported SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- import the image into the database Image.importFrom(ctx, 'file', 'ORDIMGDIR', 'jdoe.gif'); -- update the image object UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
export(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2);
Transfers image data from a local source (localData) within an Oracle database to an external image data source.
The source plug-in context information.
The source type of the location to where the data is to be exported.
The location to where the image data is to be exported.
The name of the image object to where the data is to be exported.
After exporting image data, all image attributes remain unchanged. Source attributes: source type, source location, and source name information are updated. After calling the export method, you can call the deleteContent method to delete the content of the local data.
There is no server-side native support for the export method; this method is available for user-defined sources that can support the export method.
none
If the value of srcType is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION exception.
If the export( ) method is not supported by the source plug-in being used, an ORDSourceExceptions.METHOD_NOT_SUPPORTED exception is raised.
Calling this method within a source plug-in when any other exception is raised, raises an ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION exception.
See Appendix H for more information about these exceptions.
none
This section presents reference information on the ORDImage methods associated with image migration relative to converting old ORDImgB images and ORDImgF images to new ORDImage images.
migrateFromORDImgB(old_object ORDImgB);
Allows you to migrate old ORDImgB images to the new ORDImage object.
The old ORDImgB image.
This method copies from the source BLOB to the destination BLOB, copies all the image attributes from the old object to the new object, and sets the update time and local attribute.
none
If the value of src (old_object) is NULL, calling this method raises a NULL_SOURCE exception.
If the value of dest is NULL (ORDImage), calling this method raises a NULL_DESTINATION exception.
If the value of src.content is NULL (old.object content attribute), calling this method raises a NULL_CONTENT exception.
If the dest.source.localData value is NULL (dest ORDImage source.localData), calling this method raises a NULL_LOCAL_DATA exception.
Migrate an old ORDImgB image to a new ORDImage image:
DECLARE Image ORDSYS.ORDImage; old_image ORDSYS.ORDIMGB; BEGIN -- Select the old image SELECT imageb INTO old_image FROM old_images WHERE id = 1; -- Select the new image SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- Migrate from the old to the new Image.migrateFromORDImgB(old_image); UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
migrateFromORDImgF(old_object ORDImgF);
Allows you to migrate old ORDImgF images to the new ORDImage object.
The old ORDImgF image.
This method extracts the directory name and file name from the source and copies them to the srcLocation and srcName attributes of the destination. It also copies all image attributes from the old image object to the new image object, sets the
updateTime attribute, and clears the local attribute.
none
none
Migrate an old ORDImgF image to a new ORDImage image:
DECLARE Image ORDSYS.ORDImage; old_image ORDSYS.ORDIMGF; BEGIN -- Select the old image SELECT imagef INTO old_image FROM old_images WHERE id = 1; -- Select the new image SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- Migrate from the old to the new Image.migrateFromORDImgf(old_image); UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /