02 REFERENCE GUIDE
Converting Bitmaps into GIFs
Lotus Notes/Domino has long used a proprietary format for storage of bitmaps in rich text.  Prior to R5, this was the only way images could be stored in rich text, so all images were converted to this proprietary format when imported.  In R5 and beyond, it became possible to store GIF and JPEG images (usually image files with extensions of .gif and .jpg respectively) in a native format.  Since these formats are compressed, this allowed a much smaller storage size for the rich text.  In addition, since the web does not support the proprietary bitmap format, this allows images to be displayed without requiring conversion.

In the Midas Rich Text LSX, we offer various ways of manipulating and extracting images, but these have been limited by the Lotus proprietary bitmap format.  While Midas allows resizing and other such manipulation of bitmap images, they cannot be directly exported using the  ExportGraphic method , nor can they be extracted using the  GenerateHTML method ConvertToMime method ExportToHTML method and  ExportToMIME method , all of which convert rich text to HTML and which can therefore export the images as part of the image handling (see  Working with HTML generation for details).

Along with Midas Version 2.50, we have introduced a utility call the Genii GrabIt LSX, which can be used to grab an image from a URL.  This utility is used along with the  GraphicOffset property to retrieve the image converted by the Domino HTTP stack, and then is used to replace the existing bitmap graphic.  The  GraphicFormat property is used to ensure that only "Notes Bitmap" images will be replaced.

Installing / Using this Sample (must be followed carefully):

If the database is on a server which allows web access, change the SOURCE_SERVER constant below to the web server name used from the web.  If the database is local, you must have the ability to preview locally (comes with Designer), and you must preview some document in the web browser before starting the process.   THIS IS CRITICAL!  If you do not, you will not be able to retrieve images using Genii GrabIt LSX, and you will lose your images.

To convert, follow these steps:
  1. Make a backup of your database.
  2. Create an agent called Convert Bitmaps to GIFs and import the code below.   Make sure the agent is set to run on all selected documents.
  3. Change the SOURCE_WEB_FILEPATH constant to the correct database filepath.
  4. Change the SOURCE_WEB_VIEW constant to the view which you want used to open the documents.  It should have access to all documents.
  5. If database is local, preview a document (any document will do) in IE or Netscape.  This starts nhttp.exe, which is used to render documents using local web browser.
  6. Run the agent on a document which has a bitmap image.  If the image is still visible after running the agent, look at the BitmapStatus field through the document properties.  This may not exist, or may say "Stored", which means the agent worked.  If you try this on  document with lots of images or with large bitmap images, the size of the document can be checked to see how much space is saved (often a great deal).

Additional information and samples are available from Genii Software either on our website at http://GeniiSoft.com or by request at Support@GeniiSoft.com.  Free evaluation licenses are also available from our website or by filling out our on-line request form at http://GeniiSoft.com/showcase.nsf/WebEvalRequest.

Submitted by:
Ben Langhinrichs of Genii Software 


Example
"/" & SOURCE_WEB_VIEW & "/&qu ot; & Cstr(doc.UniversalID) & "/"& nbsp;& item.Name & "/" &  rtOnDiskGraphic.GraphicOffset & "?OpenElement&FieldElemFormat=gif"
                                  Print  graphicURL
'                                   rtGraphic.ImageInPixels = True
                                   ' *** The GrabIt LSX  is a small utility LSX which was  written just to retrieve and image
                                   ' *** from a  URL.  I use it here to retrieve  the image as rendered by the Domino
                                  ' ***  HTTP engine, which will be a GIF  file.  The LSX then saves it to  disk, where I
                                   ' *** import it into the rich  text field using Midas again.  If  it fails, the document will not
                                   ' *** be saved.
                                  Set grabimage  = New GeniiGrabIt
                                   If grabimage.RetrieveFromURL(graphicURL, " c:\temp\_grabit.gif", "") Then
                                       Call  rtGraphic.AppendImportFile("c:\temp\_grabit.gif")
                                   Else
                                        doc.BitmapStatus = "Incomplete"
                                        itemsFailed = True
                                   End If
                                   rtGraphic.Remove
                                   itemsConverted = True
                               End If
                              rtGraphic.GetNextTarget
                              rtOnDiskGraphic.GetNextTarget
                          Wend
                     End If
                  End If
             End If
         End If
     End Forall    
    
    If itemsConverted Then
         If itemsFailed Then
             doc.BitmapStatus = "Failed"
         Else
             doc.BitmapStatus =  "Stored"
             doc.Save True, False
              ExtractBitmapImages = True
         End If
    Else
         ExtractBitmapImages  = False
    End If
     Exit Function
     
ProcessError:
    Print  "ERROR in ExtractBitmapImages: " &  Error$
    ExtractBitmapImages =  False
    Exit Function
     
End Function