OT? plpython2u - Mailing list psycopg

From Nahum Castro
Subject OT? plpython2u
Date
Msg-id CABqArLimjV5Binh33sw2C8EV=p_fJstrAj-OCR0+GT_MX-JhhA@mail.gmail.com
Whole thread Raw
Responses Re: OT? plpython2u
Re: OT? plpython2u
List psycopg
Hello all.

I need to process images on my database, they are stored on a bytea column.

The process consist on scaling and I have done this so far:

CREATE OR REPLACE FUNCTION  ajustar(randstring bytea)
RETURNS bytea AS
$$
    import PIL
    from PIL import Image
    basewidth = 300
    img = randstring
    wpercent = (basewidth/float(img.size[0]))
    hsize = int((float(img.size[1])*float(wpercent)))
    img = img.resize((basewidth,hsize), PIL.Image.ANTIALIAS)
   
    return img
$$
  LANGUAGE 'plpython2u' VOLATILE;


The objective of this pl is read the bytea from the database, scale, then replace the scaled image in the database, but I don't know  what type use to pass to the variable img.

This is the query.
update personal set foto=ajustar(encode(foto, 'hex')::bytea);

Thanks in advance.
Nahum





--
Nahum Castro González
Blvd. Perdigón 214, Brisas del Lago.
CP 37207
León, Guanajuato, México
Tel (477)1950304
Cel (477)1274694

psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Speeding up unicode decoding
Next
From: Jonathan Rogers
Date:
Subject: Re: OT? plpython2u