Created
April 4, 2022 13:39
-
-
Save chtzvt/0560d057b4fb8534f97e3595de72d292 to your computer and use it in GitHub Desktop.
Generate corresponding .webp versions of images hosted on cdn.ctis.me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for f in `find . -type f | grep -v "webp"` | |
do | |
fname=`basename $f | rev | cut -d . -f2 | rev` | |
fext=`basename $f | rev | cut -d . -f1 | rev` | |
fdir=`dirname $f` | |
target="$fdir/$fname.webp" | |
# Skip if target already exists | |
if [[ -f "$target" ]]; then | |
continue | |
fi | |
imgfmts=(png jpg jpeg gif tif) | |
if [[ ${imgfmts[*]} =~ "${fext,,}" ]]; then | |
echo "Creating $target from $f" | |
convert -limit thread 8 "$f" -quality 90 -define webp:thread-level=1 "$fdir/$fname.webp" | |
#exiftool -TagsFromFile $f "-all:all>all:all" "$fdir/$fname.webp" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment