Обсуждение: To store and retrive image data in postgresql

Поиск
Список
Период
Сортировка

To store and retrive image data in postgresql

От
aravind chandu
Дата:
Hello,

          I need to store an image in postgresql database and after that i need to retrive the image back.Can you please help me how to do this?

Thank You,
Avinash.

Re: To store and retrive image data in postgresql

От
Lennin Caro
Дата:
for hot_backup and restore check this

http://www.postgresql.org/docs/8.3/static/continuous-archiving.html

for logic backup (dump) use this

http://www.postgresql.org/docs/8.3/static/app-pgdump.html



--- On Mon, 7/7/08, aravind chandu <avin_friends@yahoo.com> wrote:

> From: aravind chandu <avin_friends@yahoo.com>
> Subject: [GENERAL] To store and retrive image data in postgresql
> To: pgsql-general@postgresql.org
> Date: Monday, July 7, 2008, 7:22 PM
> Hello,
>
>
>
>           I need to store
> an image in postgresql database and after that i need to
> retrive the
> image back.Can you please help me how to do this?
>
>
>
> Thank You,
>
> Avinash.





Re: To store and retrive image data in postgresql

От
Christophe
Дата:
On Jul 7, 2008, at 12:22 PM, aravind chandu wrote:
>          I need to store an image in postgresql database and after
> that i need to retrive the image back.Can you please help me how to
> do this?

Assuming you mean an image as in a binary visual image (like a JPEG),
the data type you want is BYTEA. How to actually get BYTEA data into
and out of PostgreSQL depends on what client library and language you
are using.

If your application allows it, it is often far more efficient to
store a reference to the image in the database (such as a URI or file
path), rather than the image itself.

Re: To store and retrive image data in postgresql

От
"Brent Wood"
Дата:
>>> aravind chandu <avin_friends@yahoo.com> 07/08/08 10:30 AM >>>
Hello,

          I need to store
an image in postgresql database and after that i need to retrive the
image back.Can you please help me how to do this?



Hi,

I have been involved in building a few applications to manage this capability. In the 3 cases to date, we store the
infoabout the image in the database, including the name/path/URL to the image, and have an application retrieve the
imagefor us from this data. We have not (yet) found any added value in storing the image itself as a binary object in
thedatabase. Images are stored as files on the system. 

One (relatively) easy way to demonstrate this is using QGIS. This is able to display data stored in PostGIS tables
(PostGISadds spatial support to Postgres, so we can store a point location with an image name/path). We can plot a map
inQGIS showing the points representing photographs, and via the "action" capability in QGIS, we can create a command to
clickan image on the map & display it, retrieving the path & name from the database in order to do so.  

One PostGIS/ImageJ application we are working on does store ImageJ ROI files as binary objects in the database, but the
imagesthey are derived from is still stored outside the database as a file, with the path/name stored as database
fieldsas a pointer to the image. 

HTH,

  Brent Wood


Re: To store and retrive image data in postgresql

От
Craig Ringer
Дата:
Brent Wood wrote:
>>>> aravind chandu <avin_friends@yahoo.com> 07/08/08 10:30 AM >>>
> Hello,
>
>           I need to store
> an image in postgresql database and after that i need to retrive the
> image back.Can you please help me how to do this?
>
>
>
> Hi,
>
> I have been involved in building a few applications to manage this capability. In the 3 cases to date, we store the
infoabout the image in the database, including the name/path/URL to the image, and have an application retrieve the
imagefor us from this data. We have not (yet) found any added value in storing the image itself as a binary object in
thedatabase. Images are stored as files on the system. 

Some of the advantages to doing it in the database are:

- The image data is manipulated in the same transaction as the metadata
  in the DB, so they don't get out of sync; and

- By using the DB you can have a single authentication and remote access
  setup. You don't also need WebDAV or whatever to access and alter the
  image data.

- ... and probably much more.

However:

- Storing image data in the DB is probably much less efficient in
  storage space and for access; and

- You face possible MVCC bloat with image data when storing in the
  DB, so careful management would be needed

- ... and probably much more.


The first really cool MS-SQL feature I've heard about relates to this.
NTFS now has transaction support. I'm pretty sure I remember hearing
about MS SQL server integration for filesystem/database transactions
where database transactions can encompass alterations to files in the
filesystem as well. I don't use MS SQL server so I haven't tested those
features out.

http://msdn.microsoft.com/en-us/magazine/cc163388.aspx
http://msdn.microsoft.com/en-us/library/aa363764(VS.85).aspx

If it works as well as one might hope then it'd be a great half-way
point between these two choices. Well, except for the need to use MS-SQL ;-)

--
Craig Ringer

Re: To store and retrive image data in postgresql

От
Tino Wildenhain
Дата:
Hi,

Craig Ringer wrote:
> Brent Wood wrote:
...
>>           I need to store
>> an image in postgresql database and after that i need to retrive the
>> image back.Can you please help me how to do this?

...
> - Storing image data in the DB is probably much less efficient in
>   storage space and for access; and
> - You face possible MVCC bloat with image data when storing in the
>   DB, so careful management would be needed

>
> The first really cool MS-SQL feature I've heard about relates to this.
> NTFS now has transaction support. I'm pretty sure I remember hearing

*snip*

In that case, would that MVCC bloat not just transferred to the
filesystem? Large objects should currently give you pretty much
the same results without plug for MS-SQL :-)
And in most cases bytea as mentioned elsewhere are not so bad either
(especially for p*m-Images :-)

Cheers
Tino


Вложения