summaryrefslogtreecommitdiff
path: root/tools/gencovers.sh
blob: 454d69b8dbe0164c392b697a8719964bb65f05d7 (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
37
38
39
40
41
42
43
for F in public/*/cover.jpg public/*/cover.png
do
	echo Processing: $F
	B=$(echo $F | sed s/.jpg// | sed s/.png//)
	D=$(dirname $F)

	if [ $F -nt $D/thumbnail.png ]
	then

	PORTRAIT=$(convert $F -format '%[fx:w<h]' info:)
	SQUARE=$(convert $F -format '%[fx:w=h]' info:)

	SIZE_1X=170x200
	SIZE_2X=340x400
	SIZE_TH=120x144

	if test $PORTRAIT = 1
	then
		echo - portrait
		SIZE_1X=150x200!
		SIZE_2X=300x400!
		SIZE_TH=108x144!
	fi

	if test $SQUARE = 1
	then
		echo - square
		SIZE_1X=170x170!
		SIZE_2X=170x170!
		SIZE_TH=120x120!
	fi

	convert -colorspace RGB -resize $SIZE_TH $F -colorspace sRGB $D/thumbnail.png
	convert -colorspace RGB -resize $SIZE_1X -colorspace sRGB $F $B.1x.png
	convert -colorspace RGB -resize $SIZE_2X $F -colorspace sRGB $B.2x.png

	fi

	pngtopnm $D/thumbnail.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $D/thumbnail.jpg
	pngtopnm $B.1x.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $B.1x.jpg
	pngtopnm $B.2x.png | cjpeg -progressive -optimize -sample 1x1 -quality 95 > $B.2x.jpg

done