summaryrefslogtreecommitdiffstats
path: root/build/image-optimization.sh
blob: 65a5bb46362f40957b7f124fe9d85bb38afca501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash

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;
}

recursive_optimize_images ../