aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/minify-images.sh
blob: a6ec7104573b9781d33f78a06dc44fb793601a7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
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|recipes"`
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