views:

127

answers:

2

I have images stored in my database, when fetching these images I wish to know what the weight (20KB,90KB,etc.) per image is. How do I get this info? Thanks in advance.

+1  A: 

If it's a BLOB field then you can use the following

    SELECT OCTET_LENGTH(column) FROM table t;

but it would be really nice if we knew your dbms

Edit: you can also try the following approach (I won't supply code since I dont have delphi now)

but the idea is :

load the image into a TMemoryStream then get the size using TMemoryStream.Size

Aldo
A: 

Delphi stores images in databases using the TGraphicField which normally converts your images to a BMP blob stream before storing them.

So saving your images to a BMP file should give you a good indication on the size in your DB.

Note however that some database systems can compress the underlying blobs, and some TGraphic plugins can deliver other image formats.

So like RRUZ already commented: knowing the type of database system and image helps a lot.

--jeroen

Jeroen Pluimers