genwebgallery

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 diff
     1.1 --- a/genwebgallery	Thu Jun 12 22:01:48 2008 +0200
     1.2 +++ b/genwebgallery	Mon Jun 23 15:50:50 2008 +0200
     1.3 @@ -1,7 +1,8 @@
     1.4  #!/bin/sh
     1.5  #
     1.6  # generates a web gallery
     1.7 -# requires: ImageMagick (convert)
     1.8 +# requires: ImageMagick (mogrify)
     1.9 +#       or: resize-gd
    1.10  #
    1.11  # meillo@marmaro.de
    1.12  # http://prog.marmaro.de/genwebgallery
    1.13 @@ -20,6 +21,8 @@
    1.14  galleryTitle=""
    1.15  footer=""
    1.16  
    1.17 +resizer=""
    1.18 +
    1.19  
    1.20  
    1.21  
    1.22 @@ -88,18 +91,40 @@
    1.23  
    1.24  
    1.25  
    1.26 -checkConvert() {
    1.27 -	log "checking convert installation"
    1.28 -	if [ ! `command -v convert` ] ; then
    1.29 -		echo "Can not find 'convert' (package imagemagick)"
    1.30 +checkResizer() {
    1.31 +	log "checking resize program installation"
    1.32 +	if [ `command -v mogrify` ] ; then
    1.33 +		log "Found 'mogrify':"
    1.34 +		log "`mogrify -version`"
    1.35 +		resizer="mogrify"
    1.36 +	elif [ `command -v resize-gd` ] ; then
    1.37 +		log "Found 'resize-gd':"
    1.38 +		log "`resize-gd --version`"
    1.39 +		resizer="resize-gd"
    1.40 +	else
    1.41 +		echo "Found neither 'mogrify' (package imagemagick) nor 'resize-gd'."
    1.42  		echo "ABORT"
    1.43  		exit 2
    1.44  	fi
    1.45 -	log "convert found:"
    1.46 -	log "`convert -version`"
    1.47  }
    1.48  
    1.49  
    1.50 +# call with: resize <size> <file>
    1.51 +resize() {
    1.52 +	if [ "$resizer" = "mogrify" ] ; then
    1.53 +		mogrify -resize "${1}x${1}" "$2"
    1.54 +	elif [ "$resizer" = "resize-gd" ] ; then
    1.55 +		resize-gd "$1" "$2"
    1.56 +	else
    1.57 +		echo "No resize program available."
    1.58 +		echo "It's probably a program bug if you see this message."
    1.59 +		echo "Please contact the author or maintainer (see man page)."
    1.60 +		echo "ABORT"
    1.61 +		exit 2
    1.62 +	fi
    1.63 +	return "$?"
    1.64 +}
    1.65 +
    1.66  
    1.67  usage() {
    1.68  	echo "usage: $PROGRAM [OPTIONS] PICTURES"
    1.69 @@ -212,7 +237,7 @@
    1.70  log "thumbnail size:       ${sizeThumb}px"
    1.71  log "overwrite output dir: $overwrite"
    1.72  log
    1.73 -checkConvert
    1.74 +checkResizer
    1.75  log
    1.76  
    1.77  
    1.78 @@ -232,12 +257,15 @@
    1.79  	log "processing file: $file"
    1.80  
    1.81  	# copy and resize pics
    1.82 -	convert "$i" -resize ${sizePic}x${sizePic} "$targetDir/$file"
    1.83 +	cp "$i" "$targetDir/$file"
    1.84 +	resize "$sizePic" "$targetDir/$file"
    1.85  	if [ $? -ne 0 ] ; then
    1.86  		log "  skipping"
    1.87 +		rm "$targetDir/$file"
    1.88  		continue
    1.89  	fi
    1.90 -	convert "$i" -resize ${sizeThumb}x${sizeThumb} "$targetDir/_$file"
    1.91 +	cp "$i" "$targetDir/_$file"
    1.92 +	resize "$sizeThumb" "$targetDir/_$file"
    1.93  
    1.94  	# generate pic page
    1.95  	echo `insertHeader` > "$targetFile"