diff options
Diffstat (limited to 'gal')
-rwxr-xr-x | gal | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/gal b/gal index 70a92dd..83ea478 100755 --- a/gal +++ b/gal @@ -13,6 +13,8 @@ QUALITY=70 THUMBNAIL_RESOLUTION=250 RESOLUTION=1500 +EXTENSIONS="jpg JPG jpeg JPEG png PNG" + ## ================= [ -z $1 ] && echo "You need to pass photos dir" && exit 1 @@ -21,7 +23,8 @@ RESOLUTION=1500 PHOTOS=$1 OUTPUT=$2 TITLE=${TITLE:-$(basename $OUTPUT)} -mkdir -p $2/{photos,thumbs} +mkdir -p $2/photos +mkdir -p $2/thumbs ## Generate index.html menu file cp $(dirname $(readlink -f $0))/style.css $OUTPUT @@ -43,10 +46,14 @@ cat > $OUTPUT/index.html <<EOF <div class="tiles"> EOF +[ -f $OUTPUT/photo_list ] && echo "Replacing existing photo_list" && rm $OUTPUT/photo_list + +for ext in $EXTENSIONS; do + for f in `find $PHOTOS -name "*.$ext"`; do + filename=$(basename $f) -for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do - filename=$(basename $f) - [ -f $f ] && cat >> $OUTPUT/index.html <<EOF + ## Add to index.html + [ -f $f ] && cat >> $OUTPUT/index.html <<EOF <div class="tile"> <a href="photos/$filename"> <picture> @@ -57,8 +64,20 @@ for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do </a> </div> EOF + + ## Add to photo_list + [ -f $f ] && echo $filename >> $OUTPUT/photo_list + + ## Optimize image + echo "Optimizing $filename" + [ -f $f ] && convert -auto-orient -strip -quality $QUALITY -resize x$RESOLUTION "$f" "$OUTPUT/photos/$filename" && \ + convert -auto-orient -strip -quality $QUALITY -resize x$THUMBNAIL_RESOLUTION "$f" "$OUTPUT/thumbs/$filename" && \ + cwebp -q $QUALITY -resize 400 0 $f -o "$OUTPUT/thumbs/${filename%.*}.webp" + + done done +## Add footer cat >> $OUTPUT/index.html <<EOF </div> <footer> @@ -69,28 +88,6 @@ cat >> $OUTPUT/index.html <<EOF </html> EOF -## Generate photo_list -echo "Generating photo_list" - -[ -f $OUTPUT/photo_list ] && echo "Replacing existing photo_list" && rm $OUTPUT/photo_list - -for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do - filename=$(basename $f) - [ -f $f ] && cat >> $OUTPUT/photo_list <<EOF -$filename -EOF -done - -## Optimize images - -for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do - filename=$(basename $f) - echo "Optimizing $filename" - [ -f $f ] && convert -auto-orient -strip -quality $QUALITY -resize x$RESOLUTION "$f" "$OUTPUT/photos/$filename" && \ - convert -auto-orient -strip -quality $QUALITY -resize x$THUMBNAIL_RESOLUTION "$f" "$OUTPUT/thumbs/$filename" && \ - cwebp -q $QUALITY -resize 400 0 $f -o "$OUTPUT/thumbs/${filename%.*}.webp" -done - ## Create zip archive zip $OUTPUT/"archive_$TITLE.zip" -r $OUTPUT/photos |