Simple web-gallery
Материал из RSU WiKi
#!/bin/bash # Copyright (c) 2007 Juriy Strashnov. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # Output directory OUTDIR="web" # Cheking if all needed programs are installed for PROGZ in convert sed; do WPROGZ=`which $PROGZ` if test $? -ne 0; then # Error message is printed by 'which' exit 1 fi done echo echo -n "Converting" for i in *; do mv $i `echo $i|sed -e "s/.JPG/.jpg/g"`; done mkdir $OUTDIR touch "$OUTDIR/index.html" echo "<html><body><div>">$OUTDIR/index.html for i in `ls *.jpg` do echo -n "." RSIZE=`echo $i | sed -e s/.jpg$/-resized.jpg/` THUMB=`echo $i | sed -e s/.jpg$/-tn.jpg/` convert -resize 800x600 "$i" "$OUTDIR/$RSIZE" convert -resize 320x240 -quality 50 "$i" "$OUTDIR/$THUMB" # Web gallery echo "<a href=\"$RSIZE\"><img src=\"$THUMB\"></a>">>$OUTDIR/index.html # URLs to copy-paste #echo "<a href=\"$RSIZE\"><img src=\"$THUMB\"></a>">>$OUTDIR/index.html done echo "</div></body></html>">>$OUTDIR/index.html echo " Done!"
References
- Полезности для работающих в командной строке *nix
- Advanced Bash-Scripting Guide. An in-depth exploration of the art of shell scripting