changeset 42:8f69055cf7ed

switched from convert to mogrify; added support for resize-gd
author schnalke@localhost.localdomain
date Mon, 23 Jun 2008 15:50:50 +0200
parents 8bc7566a9086
children b526a65d5066
files genwebgallery
diffstat 1 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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 <size> <file>
+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"