Oracle8 Image Cartridge User's Guide Release 8.0.4 A55713-02 |
|
Oracle8 Image Cartridge consists of two object data types:
The cartridge includes four user-visible procedures:
When you are storing or copying images, 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); grant select, update on ordimgtab to ordsys; 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;
The ORDImgB object data type (ODT) is used for basic storage and retrieval of image data within an Oracle database. This object data 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 ORDImgB), 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 BLOB) );
Where:
In PL/SQL data is moved with the DBMS LOB package. From the client, data is moved via OCI LOB calls. The ORDimgB ODT does not supply piece-wise routines for moving data.
The ORDImgF object data 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 data 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 ORDImgB), MEMBER PROCEDURE setProperties(SELF IN OUT ORDImgF), MEMBER PROCEDURE processCopy(command IN VARCHAR2, dest IN OUT BLOB) );
Where:
copyContent (dest IN OUT BLOB);
Copy an image without changing it.
The destination of the new image.
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);
process (command IN VARCHAR2 );
Perform 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.
Change one or more of the image attributes shown in the following table:
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"');
processCopy (command IN VARCHAR2,
dest IN OUT BLOB);
Copy an image BLOB 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 3-1, "Image Processing Parameters".
Copy an image, changing the file format, compression format, and data format in the destination image:
create or replace procedure 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; end;
setProperties();
Write the characteristics of an image (BLOB or BFILE) into the appropriate attribute fields.
None
After you have copied or stored an image, call this procedure to set the current characteristics of the new content.
This procedure sets the following information about an image:
Select the type, and then set the attributes using the setProperties procedure.
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