summaryrefslogtreecommitdiff
path: root/bin/make_gallery
blob: 1b2422da6bbf3c68d844a12d98f8f5859b61b711 (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
44
45
46
47
48
49
50
51
#!/bin/sh

thumb_dir="${THUMB_DIR:-thumbs}"
thumb_width="${THUMB_WIDTH:-240}"
mkdir -p "$thumb_dir"

main() {

gallery=$(
	for image in "$@"
	do
		thumb="${thumb_dir}/thumb_$(basename $image)"
		test -f "$thumb" || gm convert "$image" -resize "$(( thumb_width * 2 ))" "$thumb"
		cat <<EOF
<a href="$image">
	<div class="thumb"><img src="$thumb"></div>
</a>
EOF
	done)

cat <<EOF
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
	div.thumb {
		width: ${thumb_width}px;
		height: ${thumb_width}px;
		line-height: ${thumb_width}px;
		text-align: center;
		padding: 5px;
		float: left;
	}
	div.thumb:hover {
		background-color: #e1e1e1;
	}
	img {
		max-width: 100%;
		max-height: 100%;
		vertical-align: middle;
	}
</style>
</head>
<body>
$gallery
</body>
</html>
EOF
}

main "$@"