From 66be55f003c813427a8c5d07ab63082a3291c36e Mon Sep 17 00:00:00 2001 From: Vijay Raghavan Aravamudhan Date: Sun, 11 Oct 2020 17:55:00 +0530 Subject: Minify images using ImageOptim (lossless compression) (#326) --- scripts/minify-images.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 scripts/minify-images.sh (limited to 'scripts/minify-images.sh') diff --git a/scripts/minify-images.sh b/scripts/minify-images.sh new file mode 100755 index 0000000..c248e08 --- /dev/null +++ b/scripts/minify-images.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +# Note: This script is needed due to this bug: https://github.com/imagemin/imagemin/issues/348 +# once the above is fixed, we should simply be able to specify the input directory where all image files are to be processed recursively +FILES=`find . -name "*.jpg" -o -name "*.jpeg" -o -name "*.bmp" -o -name "*.png" -type f | GREP_OPTIONS= egrep -v "node_modules"` +for file in $FILES; do + echo "Minifying file: $file" + size_before=`/usr/bin/du $file | cut -f1` + npx imagemin $file > $file.tmp && mv $file.tmp $file + size_after=`/usr/bin/du $file | cut -f1` + echo "$size_before -> $size_after" +done -- cgit v1.2.3-70-g09d2