diff options
author | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-02-06 16:03:45 +0100 |
---|---|---|
committer | Patryk Niedźwiedziński <pniedzwiedzinski19@gmail.com> | 2021-02-06 16:03:45 +0100 |
commit | 2ced3e9d3f2eb112105f8ece90485a2f0ee2357a (patch) | |
tree | 403349066756565b0477ecdc8c4c1e6b433bf093 /gal | |
parent | 5c0f2e953c8cb87bdf8eb76424061ec72b4a6ad9 (diff) | |
download | galier-2ced3e9d3f2eb112105f8ece90485a2f0ee2357a.tar.gz galier-2ced3e9d3f2eb112105f8ece90485a2f0ee2357a.zip |
Add webp
Diffstat (limited to 'gal')
-rwxr-xr-x | gal | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gal b/gal index b7a5c5f..80d6478 100755 --- a/gal +++ b/gal @@ -48,7 +48,11 @@ for f in $PHOTOS/*.{jpg,JPG,jpeg,JPEG,png,PNG}; do [ -f $f ] && cat >> $OUTPUT/index.html <<EOF <div class="tile"> <a href="photos/$filename"> - <img src="thumbs/$filename" alt="$filename" /> + <picture> + <source srcset="thumbs/${filename%.*}.webp" type="image/webp"> + <source srcset="thumbs/$filename" type="image/${filename##*.}"> + <img src="thumbs/$filename" alt="$filename" /> + </picture> </a> </div> EOF @@ -81,5 +85,6 @@ 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" + convert -auto-orient -strip -quality $QUALITY -resize x$THUMBNAIL_RESOLUTION "$f" "$OUTPUT/thumbs/$filename" && \ + cwebp -q $QUALITY "$OUTPUT/thumbs/$filename" -o "$OUTPUT/thumbs/${filename%.*}.webp" done |