Board index » delphi » store image in interbase or store the location of the image file in interbase?

store image in interbase or store the location of the image file in interbase?

Hi, I used to just store the location of an image file in the interbase.  I
knew it could be done that store the image file in the interbase  but I
don't know exactly how?  the insert into statment will not be the same as
store the text value into the database, right? so the select statment will
be different too, right?

Plus, how is the performance and the size of the database? will that be a
problem if a lot of images files stored in the Interbase ?

What is good practice store the image in the database or store the image
location in the databse?  Could anyone give me some advice on in which cases
I should use which approach.  Thanks!

Hui

 

Re:store image in interbase or store the location of the image file in interbase?


Use streams to read/write the image from a BLOB field...

eg Read an image from a file:

ImageFileStream := TFileStream.Create(ImageFileName, fmOpenRead);

eg open Blob field for writing

ImageFieldStream := MyDataSet.CreateBlobStream(MyImageField, bmWrite);

eg copy image to blob

ImageFieldStream.CopyFrom(ImageFileStream, ImageFileStream.Size);

& vice versa... You'll find all this in the Help files....

Generally: better/safer to store images in db (linking to external locations
is messy and risky)- but really depends on what you're doing??? If it's
photo's of people, say, then you could store nice small size-controlled JPGs
(not huge BMPs) and store a large number of them in IB without unreasonable
growth in db size (although naturally they will take a fair bite of storage
if you have enough of them, but no more than storing them as separate
files!) or problems with performance (which shouldn't have much to do with
how many per se). If you DO have lots, it's probably ESPECIALLY better to
store them in the db rather than have oodles of image files all over the
place!

--
Brent Rose
brentr...@paradise.net.nz

Re:store image in interbase or store the location of the image file in interbase?


If you have to use bmp then compress before saving to blob, or make sure you
use GIF,JPG,PNG which are compressed.

Other Threads