diff --git a/scripts/pngtowebp.sh b/scripts/pngtowebp.sh index 6b21a0f..a6ee16c 100755 --- a/scripts/pngtowebp.sh +++ b/scripts/pngtowebp.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail -fd -tf png$ static/uploads -x cwebp -lossless -mt {} -o {.}.webp -fd -tf png$ static/uploads -X rm -v +function convert_to_webp() { + local DIR + DIR="${1}" + fd -tf png$ "${DIR:?}" -x cwebp -lossless -mt {} -o '{.}.webp' + fd -tf png$ "${DIR:?}" -X rm -v +} + +convert_to_webp static/uploads +convert_to_webp content/posts