Oracle8i interMedia Audio, Image, and Video User's Guide and Reference
Release 8.1.5

A67299-01

Library

Product

Contents

Index

Prev Next

4
ORDImage Reference Information

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.


Note:

If you manipulate the image data itself (by either directly modifying the BLOB or changing the external source), then you must ensure that the object attributes stay synchronized and the update time is modified; otherwise, the object attributes will not match the image data.  


Methods invoked at the ORDSource level that are handed off to the source plug-in for processing have ctx (RAW(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)).


Note:

In the current release, not all source plug-ins will use the ctx argument, but if you code as previously described, your application should work with any current or future source plug-in.  


4.1 Object Types

Oracle8i interMedia describes the ORDImage object type, which supports the storage, management, and manipulation of image data.


ORDImage Object Type

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:

4.2 Methods

This section presents reference information on the Oracle8i interMedia methods used for image data manipulation. These methods are described in the following groupings:

ORDImage Methods Associated with copy Operations

ORDImage Methods Associated with process Operations

ORDImage Methods Associated with properties set and check Operations

ORDImage Methods Associated with image Attributes

ORDImage Methods Associated with the local Attribute

ORDImage Methods Associated with the date Attribute

ORDImage Methods Associated with the mimeType Attribute

ORDImage Methods Associated with the source Attribute

ORDImage Methods Associated with Image Migration

4.2.1 Example Table Definitions

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:

EMP Table Definition


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.

EMP and OLD_IMAGES Table Definitions


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;

/

4.2.2 ORDImage Methods Associated with Copy Operations

This section presents reference information on the ORDImage method associated with the copy operation.


copy( ) Method

Format


copy(dest IN OUT ORDImage);

Description

Copies an image without changing it.

Parameters

dest

The destination of the new image.

Usage

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.

Pragmas

none

Exception

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.

Example

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;

/



4.2.3 ORDImage Methods Associated with Process Operations

This section presents reference information on the ORDImage methods associated with the process operation.


process( ) Method

Format


process(command IN VARCHAR2);

Description

Performs one or more image processing operations on a BLOB, writing the image back on to itself.

Parameters

command

A list of image processing operations to perform on the image.

Usage

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.

Table 4-1 Image Processing Operators
Operator Name  Usage  Values 

compressionFormat  

Compression type/format  

JPEG, SUNRLE, BMPRLE, TARGARLE, LZW, LZWHDIFF, FAX3, FAX4, HUFFMAN3, Packbits, GIFLZW  

compressionQuality  

Compression quality  

MAXCOMPRATIO, MAXINTEGRITY, LOWCOMP, MEDCOMP, HIGHCOMP  

contentFormat  

Image type/pixel/data format  

MONOCHROME, 8BITGRAYSCALE, 8BITGREYSCALE, 8BITLUT, 24BITRGB  

cut  

Window to cut or crop (origin.x origin.y width height)  

(Integer Integer Integer Integer)
maximum value is 65535  

fileFormat  

File format of the image  

BMPF, CALS, GIFF, JFIF, PICT, RASF, RPIX, TGAF, TIFF  

fixedScale  

Scale to a specific size in pixels (width, height)  

(INTEGER INTEGER)  

maxScale  

Scale to a specific size in pixels, while maintaining the aspect ratio (maxWidth, maxHeight)  

(INTEGER INTEGER)  

scale  

Scale factor (for example, 0.5 or 2.0)  

<FLOAT> positive  

xScale  

X-axis scale factor (default is 1)  

<FLOAT> positive  

yScale  

Y-axis scale factor (default is 1)  

<FLOAT> positive  

Table 4-2 Additional Image Processing Operators for Raw Pixel and Foreign Images
Operator Name  Usage  Values 

channelOrder  

Indicates the relative position of the red, green, and blue channels (bands) within the image.  

RGB (default), RBG, GRB, GBR, BRG, BGR  

inputChannels  

For multiband images, specify either one (grayscale) or three integers indicating which channels to assign to red (first), green (second), and blue (third). Note that this parameter affects the source image, not the destination.  

INTEGER or
INTEGER INTEGER INTEGER  

interleave  

Controls band layout within the image:
Band Interleaved by Pixel
Band Interleaved by Line
Band Sequential  

BIP (default), BIL, BSQ  

pixelOrder  

If NORMAL, then the leftmost pixel appears first in the image.  

NORMAL (default), REVERSE  

scanlineOrder  

If NORMAL, then the top scanline appears first in the image.  

NORMAL (default), INVERSE  


Note:

When specifying values that include floating-point numbers, you must use double quotation marks ("") around the value. If you do not, the wrong values may be passed and you will get incorrect results.  


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.

Pragmas

none

Exception

If data is not local or the source.localData attribute is not initialized, calling this method raises a DATA_NOT_LOCAL exception.

Example

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( ) Method

Format


processCopy(command IN     VARCHAR2, 

            dest    IN OUT ORDImage);

Description

Copies an image stored internally or externally to another image stored internally in a BLOB.

Parameters

command

A list of image processing changes to make for the image in the new copy.

dest

The destination of the new image.

Usage

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.

Pragmas

none

Exception

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.

Example

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;

/



4.2.4 ORDImage Methods Associated with Properties Set and Check Operations

This section presents reference information on the ORDImage methods associated with the properties set and check operations.


setProperties Method

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 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.

Parameters

none

Usage

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.

Pragmas

none

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.

Example

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( ) Method for Foreign Images

Format


setProperties(description IN VARCHAR2);

Description

Allows you to write the characteristics of a foreign image into the appropriate attribute fields.


Note:

This method will not set the MIME type attribute. You must invoke the setMimeType( ) method to set the MIME type for foreign images.  


Parameters

description

Specifies the image characteristics to set for the foreign image.

Usage


Note:

Once you have set the properties for a foreign image, it is up to you to keep the properties consistent. If interMedia image detects an unknown file format, it will not implicitly set the properties.  


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.

Table 4-3 Image Characteristics for Foreign (Headerless) Files
Field  Data Type  Description 

CompressionFormat  

STRING  

Value must be CCITG3, CCITG4, or NONE (default).  

DataOffset  

INTEGER  

The offset allows the image to have a header that interMedia image does not try to interpret. Set the offset to avoid any potential header. The value must be a positive integer less than the LOB length. Default is zero.  

DefaultChannelSelection  

INTEGER  

For multiband images, specify either one (grayscale) or three integers indicating which channels to assign to red (first), green (second), and blue (third).  

Height  

INTEGER  

Height of the image in pixels. Value must be a positive integer. There is no default, thus a value must be specified.  

Interleave  

STRING  

Band layout within the image. Valid styles are:

  • BIP (default) Band Interleaved by Pixel

  • BIL Band Interleaved by Line

  • BSQ Band Sequential

 

NumberOfBands  

INTEGER  

Value must be a positive integer less than 255 describing the number of color bands in the image. Default is 3.  

PixelOrder  

STRING  

If NORMAL (default), the leftmost pixel appears first in the file. If REVERSE, the rightmost pixel appears first.  

ScanlineOrder  

STRING  

If NORMAL (default), the top scanline appears first in the file. If INVERSE, then the bottom scanline appears first.  

UserString  

STRING  

A 4-character descriptive string. If used, the string is stored in the fileFormat field, appended to the file format ("OTHER:"). Default is blank and fileFormat is set to "OTHER".  

Width  

INTEGER  

Width of the image in pixels. Value must be a positive integer. There is no default, thus a value must be specified.  

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'.

Pragmas

none

Exception

If the description attribute value is NULL, calling this method raises a NULL_PROPERTIES_DESCRIPTION exception.

Example

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 Method

Format


checkProperties RETURN BOOLEAN;

Description

Verifies that the properties stored in attributes of the image object match the properties of the image. This method should not be used for foreign images.

Parameters

none

Usage

Use this method to verify that the image attributes match the actual image.

Pragmas

none

Exception

none

Example

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;

/

4.2.5 ORDImage Methods Associated with Image Attributes

This section presents reference information on the ORDImage methods associated with the image attributes.


getHeight Method

Format


getHeight RETURN INTEGER;

Description

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.

Parameters

none

Usage

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

Example

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 Method

Format


getWidth RETURN INTEGER;

Description

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.

Parameters

none

Usage

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)

Exception

none

Example

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 Method

Format


getContentLength RETURN INTEGER;

Description

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.

Parameters

none

Usage

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)

Exception

none

Example

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 Method

Format


getFileFormat RETURN VARCHAR2;

Description

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.

Parameters

none

Usage

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)

Exception

none

Example

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 Method

Format


getContentFormat RETURN VARCHAR2;

Description

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.

Parameters

none

Usage

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)

Exception

none

Example

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 Method

Format


getCompressionFormat RETURN VARCHAR2;

Description

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.

Parameters

none

Usage

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)

Exception

none

Example

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;

4.2.6 ORDImage Methods Associated with the local Attribute

This section presents reference information on the ORDImage methods associated with the local attribute.


setLocal Method

Format


setLocal;

Description

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.

Parameters

none

Usage

Sets the local attribute to 1, meaning the data is stored locally in the localData attribute.

Pragmas

none

Exception

If the source.localData attribute value is NULL, calling this method raises a NULL_LOCAL_DATA exception.

Example

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 Method

Format


clearLocal;

Description

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.

Parameters

none

Usage

This method sets the local attribute to a 0, meaning the data is stored externally or outside of Oracle8i.

Pragmas

none

Exception

none

Example

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 Method

Format


isLocal RETURN BOOLEAN;

Description

Returns TRUE if the data is stored locally in a BLOB or FALSE if the data is stored externally.

Parameters

none

Usage

If the local attribute is set to 1 or NULL, this method returns TRUE, otherwise this method returns FALSE.

Pragmas

Pragma RESTRICT_REFERENCES(isLocal, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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;

/

4.2.7 ORDImage Methods Associated with the date Attribute

This section presents reference information on the ORDImage methods associated with the date attribute.


getUpdateTime Method

Format


getUpdateTime RETURN DATE;

Description

Returns the time when the object was last updated.

Parameters

none

Usage

none

Pragmas

PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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( ) Method

Format


setUpdateTime(current_time DATE);

Description

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.

Parameters

current_time

The timestamp to be stored. Default is SYSDATE.

Usage

You must invoke this method any time you modify the image data yourself.

Pragmas

none

Exception

none

Example

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;

/

4.2.8 ORDImage Methods Associated with the mimeType Attribute

This section presents reference information on the ORDImage methods associated with the mimeType attribute.


getMimeType Method

Format


getMimeType RETURN VARCHAR2;

Description

Returns the MIME type for the image data. This is a simple accessor method that returns the value of the mimeType attribute.

Parameters

none

Usage

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.

Pragmas

PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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( ) Method

Format


setMimeType(mime IN VARCHAR2);

Description

Allows you to set the MIME type of the image data.

Parameters

mime

The MIME type.

Usage

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.

Pragmas

none

Exception

none

Example

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;



4.2.9 ORDImage Methods Associated with the source Attribute

This section presents reference information on the ORDImage methods associated with the source attribute.


getContent Method

Format


getContent RETURN BLOB;

Description

Returns a handle to the local LOB storage, that is the BLOB within the ORDImage object.

Parameters

none

Usage

none

Pragmas

PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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 Method

Format


getBFILE RETURN BFILE;

Description

Returns the LOB locator of the BFILE containing the image.

Parameters

none

Usage

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.

Pragmas

PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS)

Exception

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.

Example


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 Method

Format


deleteContent;

Description

Deletes the local data from the current local source (localData).

Parameters

none

Usage

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.

Pragmas

none

Exception

none

Example

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( ) Method

Format


setSource(source_type     IN VARCHAR2,

          source_location IN VARCHAR2,

          source_name     IN VARCHAR2);

Description

Sets or alters information about the external source of the image data.

Parameters

source_type

The source type of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.

source_location

The source location of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.

source_name

The source name of the external data. See the "ORDSource Object Type" definition in Chapter 6 for more information.

Usage

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.

Pragmas

none

Exception

none

Example

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 Method

Format


getSource RETURN VARCHAR2;

Description

Returns information about the external location of the image data in URL format.

Parameters

none

Usage

Possible return values are:

Pragmas

PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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 Method

Format


getSourceType RETURN VARCHAR2;

Description

Returns a string containing the type of the external image data source.

Parameters

none

Usage

This method returns a VARCHAR2 string containing the type of the external image data source, for example 'FILE'.

Pragmas

PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS)

Exception

none

Example

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 Method

Format


getSourceLocation RETURN VARCHAR2;

Description

Returns a string containing the value of the external image data source location.

Parameters

none

Usage

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.

Pragmas

PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS, WNPS, RNDS, RNPS)

Exception

If the value of srcLocation is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_LOCATION exception.

Example

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 Method

Format


getSourceName RETURN VARCHAR2;

Description

Returns a string containing the name of the external image data source.

Parameters

none

Usage

Returns a VARCHAR2 string containing the name of the external data source, for example 'testimg.dat'.

Pragmas

PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS, WNPS, RNDS, RNPS)

Exception

If the value of srcName is NULL, then calling this method raises an ORDSourceExceptions.INCOMPLETE_SOURCE_NAME exception.

Example

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;

/


import( ) Method

Format


 MEMBER PROCEDURE import(ctx IN OUT RAW);

Description

Transfers image data from an external image data source to a local source (localData) within an Oracle database.

Parameters

ctx

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.

Usage

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.

Pragmas

none

Exception

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.

Example

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( ) Method

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 a local source (localData) within an Oracle database.

Parameters

ctx

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.

source_type

The source type of the image data.

source_location

The location from where the image data is to be imported.

source_name

The name of the image data.

Usage

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.

Pragmas

none

Exception

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.

Example

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( ) Method

Format


export(ctx             IN OUT RAW,

       source_type     IN VARCHAR2,

       source_location IN VARCHAR2,

       source_name     IN VARCHAR2);

Description

Transfers image data from a local source (localData) within an Oracle database to an external image data source.

Parameters

ctx

The source plug-in context information.

source_type

The source type of the location to where the data is to be exported.

source_location

The location to where the image data is to be exported.

source_name

The name of the image object to where the data is to be exported.

Usage

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.

Pragmas

none

Exception

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.

Example

none

4.2.10 ORDImage Methods Associated with Image Migration

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( ) Method

Format


migrateFromORDImgB(old_object ORDImgB);

Description

Allows you to migrate old ORDImgB images to the new ORDImage object.

Parameters

old_object

The old ORDImgB image.

Usage

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.

Pragmas

none

Exception

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.

Example

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( ) Method

Format


migrateFromORDImgF(old_object ORDImgF);

Description

Allows you to migrate old ORDImgF images to the new ORDImage object.

Parameters

old_object

The old ORDImgF image.

Usage

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.

Pragmas

none

Exception

none

Example

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;

/






Prev

Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index