IBM Books

Image, Audio, and Video Extenders Administration and Programming


Displaying a thumbnail-size image or video frame

A thumbnail is a miniature version of a stored image or video frame. When you store an image in the database, the Image Extender stores a thumbnail of the image in an attribute table. When you store a video in the database, the Video Extender stores in an attribute table a generic thumbnail that symbolizes the video object.

By default, the size of an image thumbnail automatically created by the Image Extender is approximately 112 x 84 pixels. The size of the generic video thumbnail that the Video Extender inserts is 108 x78 pixels. Both the image thumbnail and the generic video thumbnail are stored in GIF format. Depending on the density of data in the image or video frame, this corresponds to approximately 4.5 KB to 5 KB of data. If you store or update an image or video with user-supplied attributes, you can specify a thumbnail of a size and format that you choose.

Use the Thumbnail UDF in an SQL SELECT statement to retrieve a thumbnail from the database. Use a file reference variable to transmit the thumbnail to a file. When you specify the UDF, you need to specify the name of the column in the database table that contains the image or video handle. Then use the DBiBrowse API to display the image or video frame thumbnail.

For example, the following statements retrieve a thumbnail image and then display it:

long rc, outCount;
char Thumbnail_filename[254];
FILE *file_handle;
 
EXEC SQL BEGIN DECLARE SECTION;
  struct {
         short len
         char data[10000];
         }Thumbnail_buffer;
EXEC SQL END DECLARE SECTION;
 
EXEC SQL SELECT THUMBNAIL(PICTURE)
     INTO :Thumbnail_buffer
     FROM EMPLOYEE
     WHERE NAME = 'Anita Jones';
 
strcpy (Thumbnail_filename,"/tmp/ajones.tmb");
file_handle=fopen(Thumbnail_filename,"wb+");
outCount=fwrite(Thumbnail_buffer.data, 1, Thumbnail_buffer.len, file_handle);
fclose(file_handle);
rc = DBiBrowse (
               NULL,                        /* use the default display program */
               MMDB_PLAY_FILE,              /* thumbnail image in file */
               Thumbnail_filename,          /* thumbnail image content */
               MMDB_PLAY_WAIT);             /* wait for user to finish */


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]