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