When you store an object, you need to identify its format. The formats that you can specify are listed in Table 4. The extenders will store the image, audio, or video object in the same format as the source. For image objects only, you have the option of having the Image Extender convert the format of the stored image. If you choose to have the image format converted, you need to specify the format of the source image and the format of the target image. The target image is the image as stored.
Specify the format of the source image, audio, or video object when you store the object without format conversion. For example, the following statement in a C application program stores a bitmap (BMP) image into a database table. The content of the source is in a server file. The target image will have the same format as the source.
EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2IMAGE( CURRENT SERVER, '/employee/images/ajones.bmp', 'BMP', /*image in BMP format */ '', 'Anita''s picture') );
You can also specify a null value or empty string as the format, or for the Image Extender only, the character string ASIS. The extender will then determine the format by examining the source.
Use NULL or ASIS for recognizable formats: Specify a null value, empty string, or ASIS only if the format is recognizable to the extender, that is, if it is one of the formats listed for the extender in Table 4. Otherwise, the extender will not be able to store the object.
Specify the format of both the source and target images when you store an image with format conversion. Table 4 lists which format conversions are allowed.
In addition, you can specify conversion options that identify additional changes, such as rotation or compression, that you want to apply to the stored image. You specify each conversion option through a parameter and an associated value. The parameters and allowed values are listed in Table 5. You can request multiple changes to a stored image by specifying multiple parameter/value pairs.
In the following example, a bitmap (BMP) image, whose content is in a server file, is converted to GIF format when stored in a database table.
EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2IMAGE( CURRENT SERVER, '/employee/images/ajones.bmp', 'BMP', /* source format */ 'GIF', /* target format */ '', 'Anita''s picture') );
In the following example, the image from the previous example is converted to GIF format when stored in a database table. In addition, the image is cropped to a width of 110 pixels and a height of 150 pixels when stored, and it is compressed using LZW compression.
EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2IMAGE( CURRENT SERVER, '/employee/images/ajones.bmp', 'BMP', /* source format */ 'GIF', /* target format */ '-x 110 -y 150 -c 14', /* conversion options */ '/employee/images/ajones.gif', 'Anita''s picture') );