This repository has been archived on 2022-05-01. You can view files and clone it, but cannot push or open issues or pull requests.
www/scripts_nohugo/outils/webp.bash

52 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
#set -x
clear
########################################################################
###
##
#
# Author: Stéphane HUC
# mail: devs@stephane-huc.net
# gpg:fingerprint: CE2C CF7C AB68 0329 0D20 5F49 6135 D440 4D44 BD58
#
# License: Public Domain
#
# Git:
#
# Date: 2020/10/03
#
##
###
########################################################################
##
# Convert to webp images
##
########################################################################
#ROOT="$(dirname "$(readlink -f -- "$0")")"
########################################################################
_webp() {
if [ ! -f "${file}.webp" ]; then
case "$(file -b "${file}")" in
'GIF'*)
gif2webp -m 0 -mt "${file}" -o "${file}.webp"
;;
'JPEG'|'PNG'|'TIFF'*)
cwebp -exact -lossless -m 0 -mt -progress "${file}" -o "${file}.webp"
;;
esac
fi;
}
main() {
find . -type f -a \( \
-name "*.gif" -o -name '*.jpg' -o -name '*.jpeg' -o -name '*.png' -o -name '*.tiff' \
\) | while read -r file; do _webp; done
}
########################################################################
main