Thread: Retrieving images from Postgres with C++

Retrieving images from Postgres with C++

From
"Johan C. de Koning"
Date:
Hello,

I stored some images as bytea in a Postgres table. I use a bytea because
when I do a select on this table I want to get more then one result and in a
stream. Using the large objects method export the files to the harddisk
first and I think this will only work for one large object at a time
(correct me if I am wrong, but storing images first on the harddisk will
result in some performance penalities).

Within C++ I do a binary cursor select and get the image inside a char*. I
want this image to be used as a texture but before I can use this I need to
now some information about this image (meta data like width, height, color
depth etc). I wanted to use the libjpeg library for this, but this one is
only accepting FILE* as input. I tried searching for converting a char* to a
FILE* but it looks like this is not possible.

Does anybody have some experience with getting images outside the database
and use them I a library like libjpeg.

Thanks for your help,

Best regards,

Johan de Koning