create.sh 1.99 KB
Newer Older
Fjen Undso's avatar
Fjen Undso committed
1
2
3
4
#/bin/sh

# Trim and scale pngs in current directory according to the directories inside.
# Do some optimizing stuff afterwards.
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
# depends on: imagemagick, pngquant, optipng, advpng (advancecomp)

# Copyright (C) 2013, fjen and ci3nt
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, pulverize, distribute, synergize,
# compost, defenestrate, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# - The above copyright notice and this permission notice, or one of similar
#   effect, shall be included in all copies or substantial portions of the
#   Software.
#
# - If the Author of the Software (the "Author") needs a place to crash and
#   you have a sofa available, you should maybe give the Author a break and
#   let him sleep on your couch.
#
# - If you are caught in a dire situation wherein you only have enough time
#   to save one person out of a group, and the Author is a member of that group,
#   you must save the Author.
#
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO BLAH BLAH BLAH
## ISN'T IT FUNNY HOW UPPER-CASE MAKES IT SOUND LIKE THE LICENSE IS ANGRY AND
## SHOUTING AT YOU?!?

Fjen Undso's avatar
Fjen Undso committed
34
cd images/
35
for dir in ../ready/*; do
Fjen Undso's avatar
Fjen Undso committed
36
37
38
39
	size=${dir##*/}
	echo "Directory $size found. Starting to work on it..."
	rm -r $dir/*

40
41
	# resize
	for img in *.png; do
Fjen Undso's avatar
Fjen Undso committed
42
43
44
		convert -trim -strip -resize x$size $img $dir/$img
	done

45
	# make things small
Fjen Undso's avatar
Fjen Undso committed
46
	oldsize=$(du -s $dir | cut -f 1)
47
	pngquant --ext .png -f $dir/*.png
Fjen Undso's avatar
Fjen Undso committed
48
49
50
51
52
53
54
55
	advpng -z -4 $dir/*.png > /dev/null
	optipng -o 7 $dir/*.png > /dev/null
	newsize=$(du -s $dir | cut -f 1)
	echo "Saved $(( $oldsize - $newsize )) kB by optimizing."

	cp ../theme $dir/
	echo "Directory $size ready!"
done