image-optimization.sh 474 B

1234567891011121314151617181920
  1. #!/usr/bin/env bash
  2. function recursive_optimize_images() {
  3. cd $1;
  4. optipng -o6 -strip all *.png;
  5. jpegoptim --strip-all *.jpg;
  6. for svg in `ls *.svg`;
  7. do
  8. mv $svg $svg.opttmp;
  9. scour -i $svg.opttmp -o $svg --create-groups --enable-id-stripping --enable-comment-stripping --shorten-ids --remove-metadata --strip-xml-prolog --no-line-breaks;
  10. done;
  11. rm *.opttmp
  12. for dir in `ls -d */`;
  13. do
  14. recursive_optimize_images $dir;
  15. cd ..;
  16. done;
  17. }
  18. recursive_optimize_images ../