Skip to content

Instantly share code, notes, and snippets.

View matgou's full-sized avatar
🎯
Focusing

Mathieu Goulin matgou

🎯
Focusing
View GitHub Profile
@rominf
rominf / postgresql_resize_image.sql
Last active April 3, 2024 08:04
PostgreSQL function to resize images (uses plpythonu and python PIL)
CREATE OR REPLACE FUNCTION resize(image bytea, h integer, w integer)
RETURNS bytea
LANGUAGE plpythonu
AS $function$
if ('io' in SD) and ('StringIO' in SD) and ('Image' in SD):
io = SD['io']
StringIO = SD['StringIO']
Image = SD['Image']
else:
import io, StringIO