Oracle8i interMedia Audio, Image, and Video User's Guide and Reference Release 8.1.5 A67299-01 |
|
For release 8.1.4 and earlier, Oracle8 Image Cartridge described a set of image object types and methods that are deprecated for release 8.1.5. A deprecated feature is a feature that ships on the software kit and is working for the current release; however, it will not be enhanced in a future release, and may become obsolete and deleted in the future. These deprecated features are described here for reference and to help you migrate your release 8.1.4 and earlier image applications to release 8.1.5 interMedia image applications. This appendix describes these deprecated image object types and methods.
These deprecated features consists of two object types:
The cartridge (release 8.1.4) includes the following functions and procedures:
When you are storing or copying images in an ORDImgB object, you must first create an empty BLOB in the table. The examples in this chapter assume that the following table, ordimgtab, has been created to store three images. Three empty rows have been created as follows:
create table ordimgtab(col1 number, col2 ORDSYS.ORDImgB); insert into ordimgtab values (1, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL)); insert into ordimgtab values (2, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL)); insert into ordimgtab values (3, ORDSYS.ORDImgB(empty_blob(), NULL, NULL, NULL, NULL, NULL, NULL)); commit;
When storing images in an ORDImgF object, you must populate the type with an initializer.
create table ordimgtab(col1 number,col2 ORDSYS.ORDImgF); insert into ordimgtab values (1, ORDSYS.ORDImgF(bfilename ('ORDIMGDIR','jdoe.gif'),NULL,NULL, NULL,NULL,NULL,NULL));
The 'bfilename' argument 'ORDIMGDIR' is a directory referring to a file system directory. Note that the directory name in a bfilename constructor must be in uppercase. The following sequence creates a directory named ORDIMGDIR:
connect internal create or replace directory ORDIMGDIR as '<myimage directory>'; grant read on directory ORDIMGDIR to <user-or-role> with grant option;
The ORDImgB object type is used for basic storage and retrieval of image data within an Oracle database. This object type is defined as follows:
CREATE TYPE ORDImgB AS OBJECT ( -- TYPE ATTRIBUTES content BLOB, height INTEGER, width INTEGER, contentLength INTEGER, fileFormat VARCHAR2(64), contentFormat VARCHAR2(64), compressionFormat VARCHAR2(64), --- METHOD DECLARATION MEMBER PROCEDURE copyContent(dest IN OUT NOCOPY BLOB), MEMBER PROCEDURE setProperties(SELF IN OUT ORDImgB), MEMBER PROCEDURE process (SELF IN OUT ORDImgB, command IN VARCHAR2) MEMBER PROCEDURE processCopy(command IN VARCHAR2, dest IN OUT NOCOPY BLOB) MEMBER FUNCTION getMimeType RETURN VARCHAR2, MEMBER FUNCTION getContent RETURN BLOB, MEMBER FUNCTION getContentLength RETURN INTEGER, MEMBER PROCEDURE deleteContent (SELF IN OUT ORDImgB), MEMBER FUNCTION getHeight RETURN INTEGER, MEMBER FUNCTION getWidth RETURN INTEGER, MEMBER FUNCTION getFileFormat RETURN VARCHAR2, MEMBER FUNCTION getContentFormat RETURN VARCHAR2, MEMBER FUNCTION getCompressionFormat RETURN VARCHAR2, MEMBER FUNCTION checkProperties RETURN BOOLEAN );
where:
In PL/SQL, data is moved with the DBMS LOB package. From the client, data is moved using OCI LOB calls. The ORDImgB object type does not supply piece-wise routines for moving data.
The ORDImgF object type is used for retrieval of image data stored in external files. BFILE images are assumed to be read-only and this is reflected in the member procedures defined on the object type.
CREATE TYPE ORDImgF AS OBJECT ( -- TYPE ATTRIBUTES content BFILE, height INTEGER, width INTEGER, contentLength INTEGER, fileFormat VARCHAR2(64), contentFormat VARCHAR2(64), compressionFormat VARCHAR2(64), -- METHOD DECLARATION MEMBER PROCEDURE copyContent(dest IN OUT NOCOPY BLOB), MEMBER PROCEDURE setProperties(SELF IN OUT ORDImgF), MEMBER PROCEDURE processCopy(command IN VARCHAR2, dest IN OUT NOCOPY BLOB), MEMBER FUNCTION getMimeType RETURN VARCHAR2, MEMBER FUNCTION getContent RETURN BFILE, MEMBER FUNCTION getContentLength RETURN INTEGER, MEMBER FUNCTION getHeight RETURN INTEGER, MEMBER FUNCTION getWidth RETURN INTEGER, MEMBER FUNCTION getFileFormat RETURN VARCHAR2, MEMBER FUNCTION getContentFormat RETURN VARCHAR2, MEMBER FUNCTION getCompressionFormat RETURN VARCHAR2, MEMBER FUNCTION checkProperties RETURN BOOLEAN );
where:
checkProperties RETURN BOOLEAN;
Verifies that the properties stored in attributes of the image object match the properties of the image stored in the BLOB or BFILE. This method should not be used for foreign images.
none
BOOLEAN
Use this method to verify that the image attributes match the actual image.
Check the image attributes.
imgb1 ORDSYS.ORDImgB; properties_match BOOLEAN; ... properties_match := imgb1.checkProperties;
copyContent (dest IN OUT NOCOPY BLOB);
Copies an image without changing it.
The destination of the new image.
This method copies the image data into the supplied BLOB.
Create a copy of the image in type image1 into a BLOB called myblob:
image1.copyContent(myblob);
deleteContent;
Deletes the contents of the image.
none
Use this method to delete the contents of the image BLOB. This method works only with BLOBS, not BFILES.
Delete the image.
imgb1 ORDSYS.ORDImgB; ... imgb1.deleteContent;
getCompressionFormat RETURN VARCHAR2;
Returns the compression type of an image. This method does not actually read the LOB, it is a simple accessor method that returns the value of the compressionFormat attribute.
none
VARCHAR2
Use this method rather than accessing the compressionFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the compression type of an image:
imgb1 ORDSYS.ORDImgB; compressionFormat VARCHAR2(64); ... compressionFormat := imgb1.getCompressionFormat;
getContent RETURN BLOB; getContent RETURN BFILE;
Returns the LOB locator of the BLOB or BFILE containing the image. This is a simple accessor method that returns the value of the content attribute.
none
BLOB or BFILE, corresponding to how the image is stored.
Use this method rather than accessing the content attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the LOB locator for an image:
imgb1 ORDSYS.ORDImgB; content BLOB; ... content := imgb1.getContent;
getContentFormat RETURN VARCHAR2;
Returns the type of an image (such as monochrome or 8-bit grayscale). This method does not actually read the LOB, it is a simple accessor method that returns the value of the contentFormat attribute.
none
VARCHAR2
Use this method rather than accessing the contentFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the type of an image:
imgb1 ORDSYS.ORDImgB; contentFormat VARCHAR2(64); ... contentFormat := imgb1.getContentFormat;
getContentLength RETURN INTEGER;
Returns the size of the on-disk image in bytes. This method does not actually read the LOB, it is a simple accessor method that returns the value of the contentLength attribute.
none
INTEGER
Use this method rather than accessing the contentLength attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the content length of an image:
imgb1 ORDSYS.ORDImgB; contentLength INTEGER; ... contentLength := imgb1.getContentLength;
getFileFormat RETURN VARCHAR2
Returns the file type of an image (such as TIFF or JFIF). This method does not actually read the LOB, it is a simple accessor method that returns the value of the fileFormat attribute.
none
VARCHAR2
Use this method rather than accessing the fileFormat attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the file type of an image:
imgb1 ORDSYS.ORDImgB; fileFormat VARCHAR2(64); ... fileFormat := imgb1.getFileFormat;
getHeight RETURN INTEGER;
Returns the height of an image in pixels. This method does not actually read the LOB, it is a simple accessor method that returns the value of the height attribute.
none
INTEGER
Use this method rather than accessing the height attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the height of an image:
imgb1 ORDSYS.ORDImgB; height INTEGER; ... height := imgb1.getHeight;
getMimeType RETURN VARCHAR2;
Returns the MIME (Multipurpose Internet Mail Extension) type of an image (such as image/jpeg or image/tiff). This method returns the MIME type based on the fileFormat of the image. See Appendix A for the MIME type associated with each supported file format.
none
VARCHAR2
Use this method to obtain the MIME type of the image. The MIME type is required by Web browsers along with the image content. It tells the Web browser how to interpret the image content.
For unrecognized file formats, this method returns image/binary.
Get the MIME type of an image:
imgb1 ORDSYS.ORDImgB; mimeType VARCHAR2(64); ... mimeType := imgb1.getMimeType;
getWidth RETURN INTEGER;
Returns the width of an image in pixels. This method does not actually read the LOB, it is a simple accessor method that returns the value of the width attribute.
none
INTEGER
Use this method rather than accessing the width attribute directly to protect yourself from potential changes to the internal representation of the ORDImgB or ORDImgF object.
Get the width of an image:
imgb1 ORDSYS.ORDImgB; width INTEGER; ... width := imgb1.getWidth;
process (command IN VARCHAR2 );
Performs one or more image processing techniques on a BLOB, writing the image back on itself.
A list of image processing changes to make for the image.
You can change one or more of the image attributes shown inTable I-2. Table I-3 shows additional changes that can be made only to raw pixel and foreign images. See Appendix A for information on all the supported format combinations. See Appendix C for a more complete description of each operator.
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=LOWCOMP, xScale="2.0"'); image1.setproperties;
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 32-by-32 pixel thumbnail image, preserving the original aspect ratio:
image1.process(maxScale="32 32");
processCopy (command IN VARCHAR2, dest IN OUT NOCOPY BLOB);
Process an image BLOB or BFILE to another BLOB.
A list of image processing changes to make for the image in the new copy.
The destination of the new image.
See Table I-2, "Image Processing Operators" and Table I-3, "Additional Image Processing Operators for Raw Pixel and Foreign Images".
When using temporary LOBs, you cannot specify the same temporary LOB as both the source and destination.
Copy an image, changing the file format, compression format, and data format in the destination image:
create or replace procedure copyit is imgB1 ORDSYS.ORDImgB; imgB4 ORDSYS.ORDImgB; mycommand VARCHAR2(400); begin select col2 into imgB1 from ordimgtab where col1 = 1; select col2 into imgB4 from ordimgtab where col1 = 4 for update; command:= 'fileFormat=tiff compressionFormat = packbits contentFormat = 8bitlut'; imgB1.processcopy(mycommand,imgB4.content); imgB4.setproperties; update ordimgtab set col2 = imgB4 where col1 = 4; end;
setProperties( );
Writes the characteristics of an image (BLOB or BFILE) into the appropriate attribute fields.
none
After you have copied, stored, or processed a native format image, call this procedure to set the current characteristics of the new content.
This procedure sets the following information about an image:
Select the image, and then set the attributes using the setProperties method:
imgB1 ORDSYS.imgB; . . . select col2 into imgB1 from ordimgtab where col1 = 1 for update; imgB1.setProperties; dbms_output.put_line('image width = '|| imgB1.width ); dbms_output.put_line('image height = '|| imgB1.height ); dbms_output.put_line('image size = '|| imgB1.contentLength ); dbms_output.put_line('image file type = '|| imgB1.fileFormat ); dbms_output.put_line('image type = '|| imgB1.contentFormat ); dbms_output.put_line('image compression = '|| imgB1.compressionFormat );
Example output:
image width = 360 image height = 490 image size = 59650 image file type = JFIF image type = 24BITRGB image compression = JPEG
SetProperties(description IN VARCHAR2);
Allows you to write the characteristics of a foreign image (BLOB or BFILE) 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 B, foreign 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 I-4.
The values supplied to setProperties( ) are written to the existing ORDImgB and ORDImgF object attributes. The fileFormat is set to "OTHER:" and includes the user string, if supplied.
Select the image type, and then set the attributes using the setProperties method.
imgB1 ORDSYS.ORDIMgB; select col2 into imgB1 from ordimgtab where col1 = 1 for update; imgB1.setProperties('width=380 height=407 dataOffset=128 bandOrder=BIL
userString="LSAT"');