diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2020-10-11 17:55:00 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-11 13:25:00 +0100 |
commit | 66be55f003c813427a8c5d07ab63082a3291c36e (patch) | |
tree | 5937adf07628b2202b37a1f046df2d82c50d30b9 /scripts | |
parent | Revert "Use imagemin to minify images (#323)" (diff) | |
download | ferdium-recipes-66be55f003c813427a8c5d07ab63082a3291c36e.tar.gz ferdium-recipes-66be55f003c813427a8c5d07ab63082a3291c36e.tar.zst ferdium-recipes-66be55f003c813427a8c5d07ab63082a3291c36e.zip |
Minify images using ImageOptim (lossless compression) (#326)
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/minify-images.sh | 12 |
1 files changed, 12 insertions, 0 deletions
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 @@ | |||
1 | #!/usr/bin/env sh | ||
2 | |||
3 | # Note: This script is needed due to this bug: https://github.com/imagemin/imagemin/issues/348 | ||
4 | # once the above is fixed, we should simply be able to specify the input directory where all image files are to be processed recursively | ||
5 | FILES=`find . -name "*.jpg" -o -name "*.jpeg" -o -name "*.bmp" -o -name "*.png" -type f | GREP_OPTIONS= egrep -v "node_modules"` | ||
6 | for file in $FILES; do | ||
7 | echo "Minifying file: $file" | ||
8 | size_before=`/usr/bin/du $file | cut -f1` | ||
9 | npx imagemin $file > $file.tmp && mv $file.tmp $file | ||
10 | size_after=`/usr/bin/du $file | cut -f1` | ||
11 | echo "$size_before -> $size_after" | ||
12 | done | ||