X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1953A534DD for ; Thu, 24 Mar 2005 01:35:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05859-01 for ; Thu, 24 Mar 2005 01:34:52 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 4045052D8A for ; Thu, 24 Mar 2005 01:34:49 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2O1YeKB033643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Mar 2005 18:34:42 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2O1Ydw2060445; Wed, 23 Mar 2005 18:34:39 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2O1YdPM060444; Wed, 23 Mar 2005 18:34:39 -0700 (MST) (envelope-from mfuhr) Date: Wed, 23 Mar 2005 18:34:39 -0700 From: Michael Fuhr To: juanmime@ono.com Cc: pgsql-admin@postgresql.org Subject: Re: Resizing images contained in oid fields Message-ID: <20050324013439.GA60339@winnie.fuhr.org> References: <422CFD5E0000A55E@resmta04.ono.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <422CFD5E0000A55E@resmta04.ono.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/379 X-Sequence-Number: 16877 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/