I want to store images and other documents in a PostgreSQL table, along with a thumbnail of each image. The original document and the thumbnail would be two separate bytea fields. PostgreSQL is running on Linux.
Because the image data could come from several different applications, I'd like to have the image processing code (for creating the thumbnail) within PostgreSQL as a function, rather than each individual application having to create the thumbnail. Is there any way for PostgreSQL to be able to create a thumbnail of an image?
PostPic sounds like the Postgres extension you are looking for.
As described in their wiki you will be able to resize and create thumbnails with ease:
FUNCTION thumbnail(i image, size INT) RETURNS image
FUNCTION resize(i image, w INT, h INT) RETURNS image