Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Images On Oracle

Re: Images On Oracle

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: 2000/04/19
Message-ID: <8dk8j2$j9$1@ctb-nnrp2.saix.net>#1/1

Marilee Niemi wrote in message <38FC8009.A382FADB_at_sf.frb.org>...
>We are also building a database that will have images and will be
>accessed from the web. As a semi-newbie, the images have been a real
>pain. Text is easy, images can be difficult. You can use BLOBs to
>store the images. You can access the BLOBs from an ASP using OO4O
>(Oracle Objects for OLE). The downside to this is that the
>documentation is pretty bad. Oracles examples are often incomplete.

I beg to differ. Images are easily handled, providing you have the right client tool to do all the dirty work for you. Consider BMP's stored in an Oracle database. To provide these as JPEG images to a browser is very easy using something like Delphi as a CGI.

You use SQL SELECT to retrieve the image from Oracle and stored it in a Delphi Bitmap object. You create a JPEG object and assign the bitmap to it. BMP to JPEG conversion happens automatically. Now you create a memory data stream and save the JPEG to this memory stream. For all intents and purposes, this could have been a file stream as well, in which case you would have been creating a physical JPEG file on disk. Obviously, memory streams are faster and the JPEG which we are returning to the client only needs to exist for a very short time period.

OK, now we set the CGI object's return stream to mime type IMAGE/JPEG and pass it the memory stream pointer. This results the CGI to return the mine type as the "header" to the STDOUT of that CGI and the memory stream as the JPEG. Basically the same as the following type of thing as this very crude DOS/UNIX shell script CGI:

--
echo Content Type: image/jpeg

type image.jpeg
REM or in the case of Unix:
REM cat image.jpeg
--

Hope I explained it clearly enough - it is much simpler to demonstrate this
concept using Delphi and writing a CGI that does it.

The key issues are:
- easy retrieval of BLOB images
- easy conversion to JPEG
- easy return of that JPEG to the browser
- no need for creating physical JPEG files and cleaning up afterwards

The code to handle this is minimal. The only problem is one that is inherent
with using CGIs - performance. There are overheads in running CGIs (quickly
noticed when multiple requests are coming thru at the same time on the web
server). In addition, there's the database connection overheads per request.
However, this can be solved by using something like ISAPI/NSAPI (proprietary
web service interfaces for Microsoft and Netscape), or developing a LRWP
(Long Running Web Process). In the latter case, the "CGI" is in fact a
multithreading peer process that functions like a web server - with the
exception of course that it only handles very specific "GCI requests" (i.e.
web services request, like supplying images from a database).

If you are interested in seeing how this work in practise, I'll be glad to
supply you with a normal Delphi CGI that returns a file-based BMP as a JPEG
(source and binary).

regards,
Billy
Received on Wed Apr 19 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US