From d2cb8749b712f9e4e1ad18867105fd1a1d1a5b49 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 13 Nov 2021 09:33:01 +0100 Subject: [PATCH] Support WebP format --- resizePictures.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resizePictures.sh b/resizePictures.sh index 4508990..e2d3b43 100755 --- a/resizePictures.sh +++ b/resizePictures.sh @@ -72,8 +72,6 @@ for image in {*.jpg,*.JPG} ; do WIDTH=`identify -format "%[fx:w]" "${image}"` HEIGHT=`identify -format "%[fx:h]" "${image}"` - echo ${WIDTH}x${HEIGHT} - # Compute image ratio TMPIMAGERATIO=`bc -l <<< "${WIDTH}/${HEIGHT}"` @@ -111,6 +109,9 @@ for image in {*.jpg,*.JPG} ; do # Rezise cover and save it convert ${OPTIONS} -resize ${COVERWIDTH}x${COVERHEIGHT} "/tmp/${image}" "${DEST}/${image}" + # Convert to webp also + convert "${DEST}/${image}" -quality 50 "${DEST}/cover.webp" + # Remove temporary file rm "/tmp/${image}" else @@ -157,6 +158,9 @@ for image in {*.jpg,*.JPG} ; do composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTPNG}/${filename}.png" "${DESTPNG}/${filename}.png" convert "${DESTPNG}/${filename}.png" -type TrueColorAlpha -quality 90 -format PNG32 -background transparent -depth 8 -strip "${DESTPNG}/${filename}.png" + + # Convert png file to webp file + convert "${DESTPNG}/${filename}.png" -quality 50 "${DESTPNG}/${filename}.webp" fi fi done