Re: faster jpeg resizing with imagemagick

Replies:

  • None.

Parents:

On Friday 13 June 2003 18:26, Gerald Oskoboiny wrote:
> Does anyone know if doing this is a bad idea for some reason?

I've never noticed a problem when I did this for my thumbnails. However, I
noted I didn't use it for the "web sized" photos and your email prompted me
to go back and re-investiage for those larger images: it significantly
speeds it up, and I don't notice any image degredation.

> That part of my photo publishing process is really time consuming
> (well, just for the machine, but I have to wait around for it);
> would be nice to speed it up by a factor of 5+ :)

Indeed! Presently my script (below) is really stupid, but it works. If I
start doing this trick for the "web" photos too, that speeds a "web folder
gallery" generation for this month from 2m44s to 1m28s. Also, it'd be cool
if I detected whether an image has changed and consequently requires
regeneration...

> I wonder what the difference is between -resize and -geometry; I
> have always used -geometry.

This stuff always confused me terribly. I used to use geometry, but in some
ImageMagick release I believe I read that I should be using "size" for what
I was doing.

----------

#!/bin/bash

if [ ! -d ./images ]; then mkdir ./images; fi;
if [ ! -d ./images/thumbs ]; then mkdir ./images/thumbs; fi;

if [ -f .htaccess ]; then
   cp .htaccess images/;
   echo -e "<Files "*.jpg">\nAllow from all\n</Files>" >
images/thumbs/.htaccess
   fi;


for f in *.jpg;
do
  convert -size "700x700" -resize "600x600>" -quality 60 \
  -border 4x6 -bordercolor black \
  -comment "%c Copyright 2003 http://goatee.net/" -antialias -pointsize 12\
  -font 'helvetica' \
  -fill '#999999' -gravity SouthEast \
  -draw 'text 10,20 " 2003 http://goatee.net/"' \
  $f ./images/$f
  convert -size "160x120" -quality 60  -resize "160x120"  $f
./images/thumbs/$f;
done

webdir=`pwd | sed -e 's/hires/web/' -e s/images//`
# cp -r images/thumbs/* $webdir/thumbs/   # uncomment (and comment others)
for icons only
rm -rf $webdir
if [ ! -d $webdir ]; then mkdir $webdir; fi;
cd images;
if [ -f .htaccess ]; then cp .htaccess $webdir; fi;
cp -r * $webdir
pushd $webdir; igal > index.html; popd;
cd ..; rm -rf images

HURL: fogo mailing list archives, maintained by Gerald Oskoboiny