# HG changeset patch # User schnalke@localhost.localdomain # Date 1214229050 -7200 # Node ID 8f69055cf7eda6ba2cb1e31403058f1ca32106d7 # Parent 8bc7566a9086da7af294e12dcc3f7537db757ea0 switched from convert to mogrify; added support for resize-gd diff -r 8bc7566a9086 -r 8f69055cf7ed genwebgallery --- a/genwebgallery Thu Jun 12 22:01:48 2008 +0200 +++ b/genwebgallery Mon Jun 23 15:50:50 2008 +0200 @@ -1,7 +1,8 @@ #!/bin/sh # # generates a web gallery -# requires: ImageMagick (convert) +# requires: ImageMagick (mogrify) +# or: resize-gd # # meillo@marmaro.de # http://prog.marmaro.de/genwebgallery @@ -20,6 +21,8 @@ galleryTitle="" footer="" +resizer="" + @@ -88,18 +91,40 @@ -checkConvert() { - log "checking convert installation" - if [ ! `command -v convert` ] ; then - echo "Can not find 'convert' (package imagemagick)" +checkResizer() { + log "checking resize program installation" + if [ `command -v mogrify` ] ; then + log "Found 'mogrify':" + log "`mogrify -version`" + resizer="mogrify" + elif [ `command -v resize-gd` ] ; then + log "Found 'resize-gd':" + log "`resize-gd --version`" + resizer="resize-gd" + else + echo "Found neither 'mogrify' (package imagemagick) nor 'resize-gd'." echo "ABORT" exit 2 fi - log "convert found:" - log "`convert -version`" } +# call with: resize +resize() { + if [ "$resizer" = "mogrify" ] ; then + mogrify -resize "${1}x${1}" "$2" + elif [ "$resizer" = "resize-gd" ] ; then + resize-gd "$1" "$2" + else + echo "No resize program available." + echo "It's probably a program bug if you see this message." + echo "Please contact the author or maintainer (see man page)." + echo "ABORT" + exit 2 + fi + return "$?" +} + usage() { echo "usage: $PROGRAM [OPTIONS] PICTURES" @@ -212,7 +237,7 @@ log "thumbnail size: ${sizeThumb}px" log "overwrite output dir: $overwrite" log -checkConvert +checkResizer log @@ -232,12 +257,15 @@ log "processing file: $file" # copy and resize pics - convert "$i" -resize ${sizePic}x${sizePic} "$targetDir/$file" + cp "$i" "$targetDir/$file" + resize "$sizePic" "$targetDir/$file" if [ $? -ne 0 ] ; then log " skipping" + rm "$targetDir/$file" continue fi - convert "$i" -resize ${sizeThumb}x${sizeThumb} "$targetDir/_$file" + cp "$i" "$targetDir/_$file" + resize "$sizeThumb" "$targetDir/_$file" # generate pic page echo `insertHeader` > "$targetFile"