Re: Storing images in PostgreSQL databases (again)

Поиск
Список
Период
Сортировка
От Leonel Nunez
Тема Re: Storing images in PostgreSQL databases (again)
Дата
Msg-id 1187.201.155.188.137.1160095873.squirrel@enelserver.com
обсуждение исходный текст
Ответ на Re: Storing images in PostgreSQL databases (again)  (Jean-Christophe Roux <jcxxr@yahoo.com>)
Ответы Re: Storing images in PostgreSQL databases (again)  (Bill Moran <wmoran@collaborativefusion.com>)
Список pgsql-general
> Hi,
> If the database had built-in functions to manipulate images (make a
> thumbnail, add text ont it.., make a montage of two pictures) and I could
> write something like
> select thumbnail(image_field, 100, 100) from images_table
> that would be a good reason to go the db route versus the filesystem
> route. A database does more then storing data, it makes convenient  to
> play with them. Once my pictures are stored in the database, how do I make
> thumbnails for instance? Maybe the solution already exists; I am curious
> here. Is there a way to integrate ImageMagick into a PostgreSQL workflow?
> By the way, is it practical to set a bytea column (containing pictures) as
> primary key? That would severely slow down many operations I guess.
> JCR
>
>

With Python   and  the  python imaging library   you can do  this  :

image is a bytea  field

curs = conn.cursor ()
curs.execute( "select image from images where name = %s" ,(thename, ))
row = curs.fetchone()
if row:
   im = Image.open (StringIO.StringIO(row[0]))
   im.thumbnail (160,120 )
   imagetmp = StringIO.StringIO()
   im.save ( imagetmp  , "JPEG")
   print ("Content-type: image/jpeg\n\n")
   print ( imagetmp.getvalue())




with this you get your image  to the browser  thumbnailed
without touch  the filesystem

that's all


Leonel






В списке pgsql-general по дате отправления:

Предыдущее
От: Alexander Staubo
Дата:
Сообщение: Re: Storing images in PostgreSQL databases (again)
Следующее
От: Bill Moran
Дата:
Сообщение: Re: Storing images in PostgreSQL databases (again)