nextcloud/build/image-optimization.sh

37 lines
625 B
Bash
Raw Normal View History

2015-09-27 14:03:31 +03:00
#!/usr/bin/env bash
2013-04-13 12:01:13 +04:00
function recursive_optimize_images() {
cd "$1":
# Optimize all JPGs and PNGs
optipng -o6 -strip all *.png;
jpegoptim --strip-all *.jpg;
# Optimize all SVGs
for svg in `ls *.svg`;
do
mv $svg $svg.opttmp;
scour --create-groups \
--enable-id-stripping \
--enable-comment-stripping \
--shorten-ids \
--remove-metadata \
--strip-xml-prolog \
--no-line-breaks \
-i $svg.opttmp \
-o $svg;
done;
# Remove temporary SVGs
rm *.opttmp
# Check all subfolders
for dir in `ls -d */`;
do
recursive_optimize_images $dir;
cd ..;
done;
2013-04-13 12:01:13 +04:00
}
recursive_optimize_images ../