Support for Images Stored in BLOB Fields in HTML and DHTML Reports

How to:

Reference:

The following relational data sources support the Binary Large Object (BLOB) data type: Microsoft SQL Server, DB2, Oracle, Informix, and PostgreSQL using its BYTEA data type.

WebFOCUS StyleSheets used to produce report output in HTML or DHTML format can access a BLOB field as an image source when an instance of the BLOB field contains an exact binary copy of a GIF, JPEG, or PNG image. Images of different formats (GIF, JPEG, PNG) can be mixed within the same BLOB field. WebFOCUS can determine the format from the header of the image. The image can be inserted in report columns, headings, footings, subheadings, and subfootings.

The BLOB field must be referenced in a PRINT or LIST command in the request (aggregation is not supported). Reports containing BLOB images are supported as components in Coordinated Compound Reports.

With the following SET commands, BLOB images will work for both HTML and DHTML in all browsers:


Top of page

x
Syntax: How to Insert a BLOB Image in HTML or DHTML Report Output

For a heading, footing, subhead, or subfoot:

TYPE=headtype, [BY=byfield,] IMAGE=(blobfield), POSITION=(+xpos +ypos), SIZE=(width height), [PRESERVERATIO={ON|OFF}],$

For a report column:

TYPE=DATA, COLUMN=bloboutputfield, IMAGE=(blobfield), SIZE=(widthheight),[PRESERVERATIO={ON|OFF}] $

where:

headtype

Is HEADING, FOOTING, SUBHEAD, or SUBFOOT.

byfield

Is the sort field that generated the subhead or subfoot.

blobfield

Is any valid column reference for the BLOB field that contains the image. Note that the BLOB field must be referenced in a PRINT or LIST command in the request.

If the BLOB field is embedded in a heading, subheading, footing, or subfooting rather than a column, the StyleSheet declaration is responsible for placing the image in the heading, subheading, footing, or subfooting. To make the BLOB image accessible to the StyleSheet, the BLOB field must be referenced in the PRINT or LIST command with the NOPRINT option. Do not reference the BLOB field name in the heading, subheading, footing, or subfooting itself.

xpos ypos

Are the offsets from the top-left corner of the heading, subheading, footing, or subfooting component in the units specified by the UNITS parameter (default is inches). The default is no offset. These numbers are specified with a leading plus (+) sign to indicate that they are relative to the top-left corner of the report component, as opposed to absolute page coordinates.

width height

Specify the dimensions to which the image is to be scaled in the units specified by the UNITS parameter (default is inches).

For a heading, subheading, footing, or subfooting component: If omitted, the original dimensions of the image are used (any GIF, PNG, or JPEG image has an original, unscaled size based on the dimensions of its bitmap). You must allow an adequate offset (POSITION) for the image to begin past the text of the heading, subheading, footing, or subfooting (if any) and also must allow for adequate space to prevent the image from overlapping the lines following the component. Reserve the space for them with blank lines. This space is accounted for when computing the heading or footing height.

There are no special considerations for FOOTING BOTTOM. The space required by the footing is computed in advance based on the height of the footing, and should not be affected by BLOB images in the columns, subheads, or other components.

For a report column: If omitted, the default size is 1 inch by 1 inch. The width of the column and the spacing between the lines is automatically adjusted to accommodate the image.

bloboutputfield

Designates the column to be replaced with an image (usually this will be the image field itself). Multiple report columns can contain images.

PRESERVERATIO={ON|OFF}

Supported for GIF and JPEG images only. PRESERVERATIO=ON specifies that the aspect ratio (ratio of height to width) of the image should be preserved when it scaled to the specified SIZE. This avoids distorting the appearance of the image. The image is scaled to the largest size possible within the bounds specified by SIZE for which the aspect ratio can be maintained. OFF does not maintain the aspect ratio. OFF is the default value.


Top of page

x
Reference: File Size and Compression Considerations

Files that contain many images can be large. Scaling the images to a smaller size using the SIZE attribute does not decrease the size of the file.



Example: Inserting an Image From a BLOB Field Into a Report Column

The Microsoft SQL Server data source named retaildetail contains product information for a sports clothing and shoe retailer. The Microsoft SQL Server data source named retailimage has the same product ID field as retaildetail and has an image of each product stored in a field named prodimage whose data type is BLOB.

The following Master File describes the Microsoft SQL Server data source named retaildetail.

FILENAME=RETAILDETAIL, SUFFIX=SQLMSS  , $
  SEGMENT=SEG01, SEGTYPE=S0, $
    FIELDNAME=FOCLIST, ALIAS=FOCLIST, USAGE=I5, ACTUAL=I4, $
    FIELDNAME=PRODUCTID, ALIAS=ProductId, USAGE=A5, ACTUAL=A5,
      MISSING=ON, $
    FIELDNAME=DEPARTMENT, ALIAS=Department, USAGE=A10, ACTUAL=A10,
      MISSING=ON, $
    FIELDNAME=CATEGORY, ALIAS=Category, USAGE=A30, ACTUAL=A30,
      MISSING=ON, $
    FIELDNAME=SPORTS, ALIAS=Sports, USAGE=A30, ACTUAL=A30,
      MISSING=ON, $
    FIELDNAME=GENDER, ALIAS=Gender, USAGE=A10, ACTUAL=A10,
      MISSING=ON, $
    FIELDNAME=BRAND, ALIAS=Brand, USAGE=A25, ACTUAL=A25,
      MISSING=ON, $
    FIELDNAME=STYLE, ALIAS=Style, USAGE=A25, ACTUAL=A25,
      MISSING=ON, $
    FIELDNAME=COLOR, ALIAS=Color, USAGE=A25, ACTUAL=A25,
      MISSING=ON, $
    FIELDNAME=NAME, ALIAS=Name, USAGE=A80, ACTUAL=A80,
      MISSING=ON, $
    FIELDNAME=DESCRIPTION, ALIAS=Description, USAGE=A1000, ACTUAL=A1000,
      MISSING=ON, $
    FIELDNAME=PRICE, ALIAS=Price, USAGE=D7.2, ACTUAL=D8,
      MISSING=ON, $

The following Master File describes the Microsoft SQL Server data source named retailimage, which has the same product ID field as retaildetail and has an image of each product stored in a field named prodimage whose data type is BLOB.

FILENAME=RETAILIMAGE, SUFFIX=SQLMSS  , $
  SEGMENT=RETAILIMAGE, SEGTYPE=S0, $
    FIELDNAME=PRODUCTID, ALIAS=PRODUCTID, USAGE=A5, ACTUAL=A5, $
    FIELDNAME=PRODIMAGE, ALIAS=F02BLOB50000, USAGE=BLOB, ACTUAL=BLOB,
      MISSING=ON, $

The following request joins the two data sources and prints product names and prices with the corresponding image. The output is generated in DHTML format.

-* Rel 7705 DHTML and HTML supports including Image stored in 
-* BLOB field in report column, heading, footing, subhead, or 
-* subfoot
-* Rel 769 supports PDF format
JOIN PRODUCTID IN RETAILDETAIL TO PRODUCTID IN RETAILIMAGE
TABLE FILE RETAILDETAIL
HEADING CENTER
"Product List"
" "
PRINT NAME/A20 PRICE PRODIMAGE AS 'PICTURE'
BY PRODUCTID NOPRINT
BY NAME NOPRINT
ON NAME UNDER-LINE
ON TABLE SET PAGE NOPAGE
-**************************
-* Lines between asterisk lines required for BLOB image support 
-* for HTML and DHTML formats.
ON TABLE SET HTMLEMBEDIMG AUTO
-* Required to support IE8 with images larger than 32K
ON TABLE SET HTMLARCHIVE ON
-*Required for image positioning in subheads in HTML reports
ON TABLE SET HTMLCSS ON 
-**************************
ON TABLE PCHOLD FORMAT DHTML
ON TABLE SET STYLE *
TYPE=REPORT,COLOR=BLUE,FONT=ARIAL, GRID=OFF,$
TYPE=HEADING, SIZE = 18, COLOR=RED,$
TYPE=DATA,COLUMN=PRODIMAGE,IMAGE=(PRODIMAGE),SIZE=(1 1),$
ENDSTYLE
END

The image is placed in the report column using the following StyleSheet declaration, which names the image field, and establishes the size and position in the column for the image.

TYPE=DATA,COLUMN=PRODIMAGE,IMAGE=(PRODIMAGE),SIZE=(1 1),$

The partial output shows that DHTML format preserves the specified spacing.

The following request generates the output in HTML format.

-* Rel 7705 DHTML and HTML supports including Image stored in 
-* BLOB field in report column, heading, footing, subhead, or
-* subfoot
-* Rel 769 supports PDF format
JOIN PRODUCTID IN RETAILDETAIL TO PRODUCTID IN RETAILIMAGE
TABLE FILE RETAILDETAIL
HEADING CENTER
"Product List"
" "
PRINT NAME/A20 PRICE PRODIMAGE AS 'PICTURE'
BY PRODUCTID NOPRINT
BY NAME NOPRINT
ON NAME UNDER-LINE
ON TABLE SET PAGE NOPAGE
-**************************
-* Lines between asterisk lines required for BLOB image support 
-* for HTML and DHTML formats.
ON TABLE SET HTMLEMBEDIMG AUTO
-* Required to support IE8 with images larger than 32K
ON TABLE SET HTMLARCHIVE ON
-*Required for image positioning in subheads in HTML reports
ON TABLE SET HTMLCSS ON 
-**************************
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
TYPE=REPORT,COLOR=BLUE, GRID=OFF, FONT=ARIAL,$
TYPE=HEADING, SIZE = 18, COLOR=RED,$
TYPE=DATA,COLUMN=PRODIMAGE,IMAGE=(PRODIMAGE),SIZE=(1 1),$
ENDSTYLE
END

The partial output shows that the spacing is different because the browser removes blank spaces for HTML report output.



Example: Inserting an Image From a BLOB Field Into a Subheading

The Microsoft SQL Server data source named retaildetail contains product information for a sports clothing and shoe retailer. The Microsoft SQL Server data source named retailimage has the same product ID field as retaildetail and has an image of each product stored in a field named prodimage whose data type is BLOB.

The following request joins the two data sources and prints product images in a subheading. The output is generated in DHTML format. It can also be generated in HTML or PDF format.

-* Rel 7705 DHTML and HTML supports including Image stored in
-* BLOB field in HTML report column, heading, footing, subhead,
-* or subfoot
-* Rel 769 supports PDF format
-*SET BASEURL='' - Required for embedded images to work. Overrides default
-* setting from WF Client.
SET BASEURL='' 
JOIN PRODUCTID IN RETAILDETAIL TO PRODUCTID IN RETAILIMAGE
TABLE FILE RETAILDETAIL
HEADING CENTER
"Product Catalog"
" "
PRINT NAME NOPRINT PRODIMAGE NOPRINT
BY PRODUCTID NOPRINT
ON PRODUCTID SUBHEAD
""
" ID: <10<PRODUCTID "
" Name: <10<NAME "
" Price: <7<PRICE "
" Image: "
""
""
""
""
""
ON TABLE SET PAGE NOPAGE
-**************************
-* Lines between asterisk lines required for BLOB image support 
-* for HTML and DHTML formats.
ON TABLE SET HTMLEMBEDIMG AUTO
-* Required to support IE8 with images larger than 32K
ON TABLE SET HTMLARCHIVE ON
-*Required for image positioning in subheads in HTML reports
ON TABLE SET HTMLCSS ON 
-**************************
ON TABLE PCHOLD FORMAT DHTML
ON TABLE SET STYLE *
TYPE=REPORT,COLOR=BLUE,FONT = ARIAL,$
TYPE=HEADING, COLOR = RED, SIZE = 16, JUSTIFY=CENTER,$
TYPE=SUBHEAD,BY=PRODUCTID,IMAGE=(PRODIMAGE),SIZE=(1 1), POSITION=(+2 +1),$
END

The partial output is.


WebFOCUS