From: | Nahum Castro <nahumcastro(at)gmail(dot)com> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | OT? plpython2u |
Date: | 2016-10-20 17:14:44 |
Message-ID: | CABqArLimjV5Binh33sw2C8EV=p_fJstrAj-OCR0+GT_MX-JhhA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda 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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2016-10-20 17:47:41 | Re: Consulta recursiva |
Previous Message | Nahum Castro | 2016-10-20 17:01:41 | Re: Consulta recursiva |
From | Date | Subject | |
---|---|---|---|
Next Message | Jonathan Rogers | 2016-10-20 18:03:21 | Re: OT? plpython2u |
Previous Message | Daniele Varrazzo | 2016-10-12 01:21:31 | Speeding up unicode decoding |