-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgallery.sh
More file actions
executable file
·131 lines (120 loc) · 2.99 KB
/
gallery.sh
File metadata and controls
executable file
·131 lines (120 loc) · 2.99 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
# getbyext.sh
# == Description ============================================================
# Simple HTML Image gallery creation script
#
# requires libjpeg-progs
# == License ================================================================
# Copyright (c) 2005, cbaoth
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
prog="`basename $0`"
title="My Gallery"
file="gallery.html"
suffix="_tn"
delete=0
bgcolor="#aaaaaa"
tndir="thumbs"
error() { echo -e "error: $1" >&2; return 0; }
usage() {
cat <<EOF
usage: $prog [options]
options:
-t TITLE page title ["$title"]
-f FILE gallery html file ["$file"]
-s SUFFIX thumbnail file suffix ["$suffix"]
-d DIR thumbnail directory name ["$tndir"]
-b RGB bgcolor ["$bgcolor"]
EOF
exit 0
}
# -y don't ask before deleting thumbs
while [ $# -ge 1 ]; do
case $1 in
-h|--help)
usage
;;
-t)
[ -z $2 ] && error "parsing args"
title="$2"
shift 2
;;
-f)
[ -z $2 ] && error "parsing args"
file="$2"
shift 2
;;
-s)
[ -z $2 ] && error "parsing args"
suffix="$2"
shift 2
;;
# -y)
# delete=1
# shift
# ;;
-d)
[ -z $2 ] && error "parsing args"
tndir="$2"
;;
-b)
[ -z $2 ] && error "parsing args"
bgcolor="$2"
shift 2
;;
*)
echo "error: parsing args"
echo "$prog --help for usage"
exit 1
;;
esac
done
#if [ $delete -eq 0 ]; then
# tncount="`ls $tndir/*${suffix}.jpg|wc -l`"
# if [ $tncount -gt 0 ]; then
# printf "ready to delete $tncount thumbs \"$tndir/*${suffix}.jpg\"? "
# read -n 1 key
# case $key in
# [yY])
# ;;
# *)
# echo
# exit 1
# ;;
# esac
# fi
#fi
rm -rf $tndir #/*${suffix}.jpg
mkdir -p $tndir
cat <<EOF > $file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$title</title>
</head>
<body bgcolor="$bgcolor">
EOF
for f in *.jpg
do x="${f%%.jpg}"
printf "processing: $f .."
djpeg -scale "1/8" -outfile $tndir/${x}${suffix}_uc.jpg $f
cjpeg -quality 60 -optimize -outfile $tndir/${x}${suffix}.jpg \
$tndir/${x}${suffix}_uc.jpg
rm -f $tndir/${x}${suffix}_uc.jpg
cat <<EOF >> $file
<a href="./$f" target="_new"><img src="./$tndir/${x}${suffix}.jpg" border="no" /></a>
EOF
echo ". done"
done
cat <<EOF >> $file
</body>
</html>
EOF