Skip to content

postpic

A PostgreSQL image type with SQL image-processing and metadata functions, backed by GraphicsMagick, plus import/export utilities.

postpic · A PostgreSQL image type with SQL image-processing and metadata functions, backed by GraphicsMagick, plus import/export utilities.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101132postpicpostpic0.9.1TYPELGPL-3.0C
Relationships
Requiresplpgsql

Usage

Sources:

postpic version 0.9.1 adds an image type backed by GraphicsMagick. SQL functions can load images from bytea or a large object, read width, height, date and EXIF-style attributes, and produce thumbnails, crops, rotations, drawings, and contact sheets.

Example

CREATE EXTENSION postpic;
CREATE TABLE pictures (id bigint GENERATED ALWAYS AS IDENTITY, body image);
INSERT INTO pictures(body) VALUES (image_from_bytea(pg_read_binary_file('/srv/import/photo.jpg')));
SELECT id, width(body), height(body), colorspace(body) FROM pictures;
SELECT thumbnail(body, 320) FROM pictures WHERE id = 1;

The example reads a server-side path and therefore requires privileged file access; applications should instead pass approved bytes through a controlled ingestion path. Image decoding runs native GraphicsMagick code inside a PostgreSQL backend, so malformed media can consume memory/CPU or hit decoder vulnerabilities. This is old code with no current PostgreSQL or GraphicsMagick compatibility statement. Restrict execution, cap input size, keep codecs patched, and evaluate only in an isolated environment.

Table reader