pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: juanmime@ono.com
Cc: pgsql-admin@postgresql.org
Subject: Re: Resizing images contained in oid fields
Date: Wed, 23 Mar 2005 18:34:39 -0700
Message-ID: <20050324013439.GA60339@winnie.fuhr.org> (raw)
In-Reply-To: <422CFD5E0000A55E@resmta04.ono.com>
References: <422CFD5E0000A55E@resmta04.ono.com>

On Mon, Mar 21, 2005 at 05:12:52PM +0100, juanmime@ono.com wrote:
> 
> I have a table where an oid field is used for saving images. I'm thinking
> about getting a little snapshot of all images without downloading the full
> images. I only want to download some entire images. I'm thinking in something
> like this:
> 
> create table images (
>   id serial primary key,
>   title varchar not null,
>   photo_id oid
> );
> 
> select title, snapshot(photo_oid, 120, 120) as snap from images
> 
> In this case, the snapshot function returns the resized snapshot of the original
> image.

Why not store the resized image in another column?  Retrieval would
probably be more efficient than running an algorithm over each image
every time you wanted to fetch the "snapshots" (thumbnails?).

> I think that the core of function could be similar to this:
> 1) Obtain the image
> 2) Resize the Image to new size
> 3) Return the Resized Image
> 
> Do you know if there exists a function like this ("snapshot")?

Not in the standard PostgreSQL installation.

> Otherwise, What is the type returned by the function ? What suitable procedure
> language should I use ? What image library for the redimension ?

I'd probably make the return type bytea.  I'm sure several of the
procedural languages (PL/Perl, PL/Tcl, PL/Python) have modules that
interface to graphics libraries that can resize images; check their
respective web sites (CPAN for Perl, etc.).  If I had to write this
function I'd probably use C and ImageMagick, but I'd be more likely
to generate the thumbnails on the client side and store them in
another column.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (3+ messages)  latest in thread

Message-ID: <20050324013439.GA60339@winnie.fuhr.org>
Permalink:  ../20050324013439.GA60339@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050324013439.GA60339@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mike@fuhr.org, juanmime@ono.com
  Subject: Re: Resizing images contained in oid fields
  In-Reply-To: <20050324013439.GA60339@winnie.fuhr.org>
  References: <422CFD5E0000A55E@resmta04.ono.com> <20050324013439.GA60339@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox