rev |
line source |
pascal@18237
|
1 #!/bin/sh
|
pascal@18237
|
2 #
|
pascal@18237
|
3 # Scanner CGI interface - Scan documents via a browser
|
pascal@18237
|
4 #
|
pascal@18237
|
5 # (C) 2015 SliTaz GNU/Linux - BSD License
|
pascal@18237
|
6 #
|
pascal@18237
|
7
|
pascal@18237
|
8 # Common functions from libtazpanel
|
pascal@18237
|
9 . lib/libtazpanel
|
pascal@18237
|
10 get_config
|
pascal@18237
|
11
|
pascal@18237
|
12 #------
|
pascal@18237
|
13 # menu
|
pascal@18237
|
14 #------
|
pascal@18237
|
15
|
pascal@18237
|
16 case "$1" in
|
pascal@18237
|
17 menu)
|
pascal@18237
|
18 TEXTDOMAIN_original=$TEXTDOMAIN
|
pascal@18237
|
19 export TEXTDOMAIN='sane'
|
pascal@18237
|
20
|
pascal@18237
|
21 cat <<EOT
|
pascal@18237
|
22 <li><a data-icon="text" href="sane.cgi"$(groups | grep -q scanner ||
|
pascal@18237
|
23 echo ' data-root')>$(_ 'Scanner')</a></li>
|
pascal@18237
|
24 EOT
|
pascal@18237
|
25 export TEXTDOMAIN=$TEXTDOMAIN_original
|
pascal@18237
|
26 exit
|
pascal@18237
|
27 esac
|
pascal@18237
|
28
|
pascal@18237
|
29 TITLE="$(_ 'TazPanel - Hardware') - $(_ 'Scanner')"
|
pascal@18237
|
30
|
pascal@18237
|
31 inrange() {
|
pascal@18237
|
32 local n=$1
|
pascal@18237
|
33 [ $1 -lt $2 ] && n=$2
|
pascal@18237
|
34 [ $1 -gt $3 ] && n=$3
|
pascal@18237
|
35 echo $n
|
pascal@18237
|
36 }
|
pascal@18237
|
37
|
pascal@18237
|
38 getgeometry() {
|
pascal@18237
|
39 CMD=""
|
pascal@18242
|
40 ARGS=""
|
pascal@18242
|
41 for i in x y l t ; do
|
pascal@18237
|
42 j=$(inrange $(xPOST geometry_$i) $(xPOST ${i}_min) $(xPOST ${i}_max))
|
pascal@18237
|
43 eval "geometry_$i=$j"
|
pascal@18237
|
44 CMD="$CMD -$i $j"
|
pascal@18242
|
45 ARGS="$ARGS $j"
|
pascal@18237
|
46 done
|
pascal@18237
|
47 for i in mode source contrast brightness ; do
|
pascal@18237
|
48 [ "$(xPOST $i)" ] && CMD="$CMD --$i '$(xPOST $i)'"
|
pascal@18237
|
49 done
|
pascal@18237
|
50 resolution=${1:-0}
|
pascal@18237
|
51 if [ $resolution -eq 0 ]; then
|
pascal@18237
|
52 resolution=$(xPOST res_min)
|
pascal@18237
|
53 width=$(GET width)
|
pascal@18237
|
54 [ ${geometry_x:-0} -le 0 ] && geometry_x=$(xPOST x_max)
|
pascal@18237
|
55 while [ $((${resolution:=150} * ${geometry_x%.*})) -lt ${width:-8192} ]; do
|
pascal@18237
|
56 resolution=$(($resolution * 2))
|
pascal@18237
|
57 done
|
pascal@18237
|
58 fi
|
pascal@18242
|
59 case "$(xPOST mode)" in
|
pascal@18242
|
60 *lack*|*ineart*) mode="-monochrome" ;;
|
pascal@18242
|
61 *ray*) mode="-colorspace gray" ;;
|
pascal@18242
|
62 *) mode="" ;;
|
pascal@18242
|
63 esac
|
pascal@18237
|
64 [ -d tmp ] || ln -s /tmp tmp
|
pascal@18237
|
65 case "$device" in
|
pascal@20172
|
66 fake*) f=$(ls fake-sane/*.png | sed q)
|
pascal@20172
|
67 [ -s "$f" ] || f=/usr/share/images/slitaz-banner.png
|
pascal@18242
|
68 c="$(echo $ARGS $(identify $f | sed \
|
pascal@18242
|
69 's/.* \([0-9]*\)x.*/\1/') $(GET width) $(POST x_max) | awk '
|
pascal@18242
|
70 function a(x) { return int(($x * $5)/ $7); }
|
pascal@18242
|
71 { printf "%dx%d+%d+%d -resize %dx%d",a(1),a(2),a(3),a(4),$6,int(($2*$6)/$1)}
|
pascal@18242
|
72 ')"
|
pascal@18252
|
73 suf="png"; [ "$1" ] && suf="pnm"
|
pascal@18242
|
74 cat <<EOT
|
pascal@18252
|
75 if convert -crop $c $mode $f /tmp/sane$$.$suf 2> /dev/null ; then
|
pascal@18252
|
76 cat /tmp/sane$$.$suf
|
pascal@18252
|
77 rm -f /tmp/sane$$.$suf
|
pascal@18242
|
78 else
|
pascal@18242
|
79 cat $f
|
pascal@18242
|
80 fi
|
pascal@18242
|
81 EOT
|
pascal@18242
|
82 ;;
|
pascal@18242
|
83 *) echo -n "scanimage -d '$(echo $device | sed 's/,.*//')' --resolution '$(inrange $resolution $(xPOST res_min) $(xPOST res_max))dpi'$CMD"
|
pascal@18242
|
84 if [ -z "$1" -a "$(which convert)" ]; then
|
pascal@18242
|
85 echo -n "> /tmp/sane$$.pnm ; convert -resize "
|
pascal@18242
|
86 echo $ARGS $(GET width) | awk '{ printf "%dx%d",$5,int(($2*$5)/$1)}'
|
pascal@18242
|
87 echo -n " /tmp/sane$$.pnm /tmp/sane$$.png ;"
|
pascal@18242
|
88 echo -n "cat /tmp/sane$$.png ; rm -f /tmp/sane$$.pn?"
|
pascal@18242
|
89 fi
|
pascal@18237
|
90 esac
|
pascal@18237
|
91 }
|
pascal@18237
|
92
|
pascal@18237
|
93 imgformat() {
|
pascal@18237
|
94 tmp=$(mktemp -u -t tazsane.XXXXXX)
|
pascal@18237
|
95 while read key name type exe pkg cmd ; do
|
pascal@18237
|
96 case "$key" in
|
pascal@18237
|
97 \#*) continue
|
pascal@18237
|
98 esac
|
pascal@18237
|
99 case "$1" in
|
pascal@18237
|
100 list)
|
pascal@18237
|
101 echo -n "<option value=\"$key\""
|
pascal@18237
|
102 [ "$(which $exe 2> /dev/null)" ] ||
|
pascal@18237
|
103 echo -n " disabled title=\"$exe not found: install $pkg\""
|
pascal@18237
|
104 [ "$key" == "pnm" ] &&
|
pascal@18237
|
105 echo -n " title=\"not supported by most browsers\""
|
pascal@18237
|
106 echo ">$key" ;;
|
pascal@18237
|
107 *)
|
pascal@18237
|
108 case "$key" in
|
pascal@18237
|
109 $(xPOST format)|'*')
|
pascal@18237
|
110 case "$HTTP_USER_AGENT" in
|
pascal@18237
|
111
|
pascal@18237
|
112 # Tazweb has no download support
|
pascal@18237
|
113 TazWe*) rm -f /tmp/$name
|
pascal@18237
|
114 eval "$(getgeometry $(xPOST resolution)) $cmd >/tmp/$name" 2> $tmp.err
|
pascal@18237
|
115 if [ -s /tmp/$name ]; then
|
pascal@18237
|
116 info="Stored in /tmp/$name ($(stat -c %s /tmp/$name) bytes)."
|
pascal@18237
|
117 else
|
pascal@18237
|
118 error="$(sed 's|$|<br />|' $tmp.err)"
|
pascal@18237
|
119 [ "$error" ] || error="I/O error"
|
pascal@18237
|
120 fi
|
pascal@18237
|
121 rm -f $tmp.* ;;
|
pascal@18237
|
122
|
pascal@18237
|
123 # Others should work
|
pascal@18237
|
124 *) header "Content-Type: $type" \
|
pascal@18237
|
125 "Content-Disposition: attachment; filename=$name" \
|
pascal@18237
|
126
|
pascal@18237
|
127 eval "$(getgeometry $(xPOST resolution)) $cmd"
|
pascal@18237
|
128 rm -f $tmp.*
|
pascal@18237
|
129 exit ;;
|
pascal@18237
|
130 esac ;;
|
pascal@18237
|
131 esac ;;
|
pascal@18237
|
132 esac
|
pascal@18237
|
133 done <<EOT
|
pascal@18237
|
134 png tazsane.png image/png convert imagemagick > $tmp.pnm; convert $tmp.pnm png:-
|
pascal@18237
|
135 jpeg tazsane.jpg image/jpeg convert imagemagick > $tmp.pnm; convert $tmp.pnm jpg:-
|
pascal@18237
|
136 jpeg2000 tazsane.jp2 image/jpeg2000-image convert imagemagick > $tmp.pnm; convert $tmp.pnm jp2:-
|
pascal@18237
|
137 tiff tazsane.tiff image/tiff convert imagemagick > $tmp.pnm; convert $tmp.pnm tiff:-
|
pascal@18237
|
138 ps tazsane.ps application/postscript convert imagemagick > $tmp.pnm; convert -page A4+0+0 $tmp.pnm ps:-
|
pascal@18237
|
139 pdf tazsane.pdf image/pdf convert imagemagick > $tmp.pnm; convert $tmp.pnm pdf:-
|
pascal@18237
|
140 ocr1 tazsane-OCR1.txt text/plain gocr gocr | gocr -
|
pascal@18237
|
141 ocr2 tazsane-OCR2.txt text/plain tesseract tesseract-ocr | tesseract stdin stdout
|
pascal@18237
|
142 pnm tazsane.pnm image/pnm true slitaz
|
pascal@18237
|
143 EOT
|
pascal@18237
|
144 }
|
pascal@18237
|
145
|
pascal@18237
|
146 xPOST() {
|
pascal@18237
|
147 [ "$preview" == "reset" ] || POST $@
|
pascal@18237
|
148 }
|
pascal@18237
|
149
|
pascal@18237
|
150 tmpreview="$(POST tmpreview)"
|
pascal@18237
|
151 find tmp/ -name 'tazsane*' -mmin +60 -prune -exec rm -f {} \;
|
pascal@18237
|
152
|
pascal@18237
|
153 device="$(POST device)"
|
pascal@18237
|
154 preview="$(POST preview)"
|
pascal@18237
|
155 info=""
|
pascal@18237
|
156 error=""
|
pascal@18237
|
157
|
pascal@18237
|
158 case " $(POST) " in
|
pascal@18237
|
159 *\ reset\ *)
|
pascal@18237
|
160 unset device tmpreview
|
pascal@18237
|
161 preview="reset" ;;
|
pascal@18237
|
162 *\ preview\ *)
|
pascal@18237
|
163 [ "$tmpreview" ] || tmpreview=$(mktemp -u -t tazsane.XXXXXX).png
|
pascal@18237
|
164 tmp=$(mktemp -u -t tazsane.XXXXXX)
|
pascal@18237
|
165 eval "$(getgeometry)" > $tmp.pnm 2> $tmp.err
|
pascal@18237
|
166 if [ -s "$tmp.pnm" ]; then
|
pascal@18237
|
167 convert $tmp.pnm $tmpreview > /dev/null 2>&1 ||
|
pascal@18237
|
168 cp $tmp.pnm $tmpreview
|
pascal@18237
|
169 else
|
pascal@18237
|
170 error="$(sed 's|$|<br />|' $tmp.err)"
|
pascal@18237
|
171 rm -f $tmpreview
|
pascal@18237
|
172 fi
|
pascal@18237
|
173 rm -f $tmp.pnm $tmp.err ;;
|
pascal@18237
|
174 *\ scan\ *)
|
pascal@18237
|
175 imgformat download ;;
|
pascal@18237
|
176 esac
|
pascal@18237
|
177
|
pascal@18237
|
178 header
|
pascal@18237
|
179 xhtml_header
|
pascal@18237
|
180 [ -n "$error" ] && msg warn "$error"
|
pascal@18237
|
181 [ -n "$info" ] && msg tip "$info"
|
pascal@18237
|
182 if [ -z "$device" ]; then
|
pascal@20172
|
183 all="$(scanimage -f '%d,%v %m|'|\
|
pascal@20172
|
184 cat - sane-fake.log fake-sane/sane-fake.log |sed 's/|/\n/g')"
|
pascal@18237
|
185 case "$(echo "$all" | wc -l)" in
|
pascal@18237
|
186 1) if [ -z "$all" ]; then
|
pascal@18242
|
187 msg warn "$(_ "No scanner found")"
|
pascal@18242
|
188 msg tip "$(_ "You can test this GUI with ")\
|
pascal@18242
|
189 <a href=\"/user/pkgs.cgi?info=fake-sane\">fake-sane</a>"
|
pascal@18237
|
190 xhtml_footer
|
pascal@18237
|
191 exit 0
|
pascal@18237
|
192 fi
|
pascal@18237
|
193 device="${all%|}" ;;
|
pascal@18242
|
194 *)
|
pascal@18242
|
195 suggested=""
|
pascal@18242
|
196 while read exe pkg msg; do
|
pascal@18242
|
197 [ "$(which $exe 2> /dev/null)" ] && continue
|
pascal@18242
|
198 suggested="$suggested
|
pascal@18242
|
199 <li><a href=\"/user/pkgs.cgi?info=$pkg\">$pkg</a> $msg</li>"
|
pascal@18242
|
200 done <<EOT
|
pascal@18242
|
201 convert imagemagick $(_ "to preview images and support more image formats")
|
pascal@18242
|
202 gocr gocr $(_ "a basic optical character recognition")
|
pascal@18242
|
203 tesseract tesseract-ocr $(_ "a better optical character recognition")
|
pascal@18242
|
204 EOT
|
pascal@18242
|
205 [ "$suggested" ] &&
|
pascal@18242
|
206 msg tip "$(_ "You may need to install:") <ol>$suggested</ol>"
|
pascal@18242
|
207 cat <<EOT
|
pascal@18237
|
208 <section>
|
pascal@18237
|
209 <header>
|
pascal@18237
|
210 <form name="scanner" method="post">
|
pascal@18237
|
211 Scanner
|
pascal@18237
|
212 <select name="device" size=1>
|
pascal@18237
|
213 EOT
|
pascal@18237
|
214 echo "$all" | awk -F, '{ if (NF > 0) print "<option value=\"" $0 "\">" 1+i++ " - " $2 }'
|
pascal@18237
|
215 cat <<EOT
|
pascal@18237
|
216 </select>
|
pascal@18237
|
217 <button data-icon="start">$(_ "Continue")</button>
|
pascal@18237
|
218 </form>
|
pascal@18237
|
219 </header>
|
pascal@18237
|
220 </section>
|
pascal@18237
|
221 EOT
|
pascal@18237
|
222 xhtml_footer
|
pascal@18237
|
223 exit 0 ;;
|
pascal@18237
|
224 esac
|
pascal@18237
|
225 fi
|
pascal@18237
|
226
|
pascal@18237
|
227 cat <<EOT
|
pascal@18237
|
228 <section>
|
pascal@20172
|
229 <form name="parameters" method="post" style="width:100%">
|
pascal@18237
|
230
|
pascal@18237
|
231 <header>
|
pascal@18237
|
232 $(echo $device | sed 's/.*,//')
|
pascal@18237
|
233 <div class="float-right">
|
pascal@18237
|
234 <button name="scan" data-icon="start">$(_ "Scan")</button>
|
pascal@18242
|
235 <button name="reset" data-icon="refresh">$(_ "Reset")</button>
|
pascal@18237
|
236 <button name="preview" data-icon="view">$(_ "Preview")</button>
|
pascal@18237
|
237 </div>
|
pascal@18237
|
238 </header>
|
pascal@18237
|
239
|
pascal@20172
|
240 <table style="width:100%">
|
pascal@18237
|
241 <tr>
|
pascal@18267
|
242 <td>
|
pascal@18267
|
243 <fieldset><legend>$(_ 'Format')</legend>
|
pascal@18237
|
244 <select name="format" size=1>
|
pascal@18237
|
245 $(imgformat list)
|
pascal@18237
|
246 </select>
|
pascal@18267
|
247 </fieldset>
|
pascal@18237
|
248 </td>
|
pascal@18237
|
249 EOT
|
pascal@18237
|
250
|
pascal@18237
|
251 if [ "$(xPOST params)" ]; then
|
pascal@18237
|
252 params="$(xPOST params | uudecode)"
|
pascal@18237
|
253 else
|
pascal@18237
|
254 params="$({
|
pascal@18237
|
255 cat "$(echo $device | sed 's/,.*//').log" 2> /dev/null ||
|
pascal@18237
|
256 scanimage --help -d "$(echo $device | sed 's/,.*//')"
|
pascal@18237
|
257 } | awk '
|
pascal@18237
|
258 function minmax()
|
pascal@18237
|
259 {
|
pascal@18237
|
260 if (match($2,"[0-9]")) {
|
pascal@18237
|
261 i=$2; sub(/\.\..*/,"",i)
|
pascal@18237
|
262 j=$2; sub(/.*\.\./,"",j)
|
pascal@18237
|
263 sub(/\..*/,"",j); sub(/[dm%].*/,"",j)
|
pascal@18237
|
264 k=$0; sub(/.* \[/,"",k); sub(/\].*/,"",k)
|
pascal@18237
|
265 print $1 " " int(k) " " int(i) " " int(j)
|
pascal@18237
|
266 }
|
pascal@18237
|
267 }
|
pascal@18237
|
268
|
pascal@18237
|
269 function enum()
|
pascal@18237
|
270 {
|
pascal@18237
|
271 i=$0
|
pascal@18237
|
272 if (index(i,"|")) {
|
pascal@18237
|
273 sub(/^ *--*[a-z]* */,"",i)
|
pascal@18237
|
274 sub(/dpi .*/,"",i); gsub(/ \[.*\].*/,"",i)
|
pascal@18237
|
275 k=$0; sub(/.* \[/,"",k); sub(/\].*/,"",k)
|
pascal@18237
|
276 gsub(/ /,"=",k)
|
pascal@18237
|
277 print $1 " " k " enum " i
|
pascal@18237
|
278 }
|
pascal@18237
|
279 else minmax()
|
pascal@18237
|
280 }
|
pascal@18237
|
281
|
pascal@18237
|
282 /Options specific to device/ { parse=1 }
|
pascal@18237
|
283 {
|
pascal@18237
|
284 if (parse != 1) next
|
pascal@18237
|
285 if (/\[inactive\]/) next
|
pascal@18237
|
286 if (match("-l-t-x-y", $1)) minmax()
|
pascal@18237
|
287 if (match("--resolution--brightness--contrast--source--mode", $1)) enum()
|
pascal@18237
|
288 }
|
pascal@18237
|
289 ')"
|
pascal@18237
|
290 fi
|
pascal@18242
|
291 output="$(n=$(echo "$params" | wc -l); echo "$params" | \
|
pascal@18242
|
292 while read name def min max ; do
|
pascal@18237
|
293 name="${name##*-}"
|
pascal@18237
|
294 def="${def//=/ }"
|
pascal@18237
|
295 if [ "$min" == "enum" ]; then
|
pascal@18237
|
296 res_min=1000000
|
pascal@18237
|
297 res_max=0
|
pascal@18267
|
298 echo "<td><fieldset><legend>$name</legend>"
|
pascal@18237
|
299 echo -n "<select name=\"$name\" size=1"
|
pascal@18237
|
300 [ "$name" == "resolution" ] && echo -n " onchange=showGeometry()"
|
pascal@18237
|
301 echo ">"
|
pascal@18237
|
302 IFS="|"; set -- $max ; unset IFS
|
pascal@18237
|
303 while [ "$1" ]; do
|
pascal@18237
|
304 echo -n "<option value=\"$1\""
|
pascal@18237
|
305 [ "$(xPOST $name)" == "$1" ] && echo -n " selected"
|
pascal@18237
|
306 [ -z "$(xPOST $name)" -a "$def" == "$1" ] && echo -n " selected"
|
pascal@18237
|
307 echo ">$(_ "$1")"
|
pascal@18237
|
308 if [ "$name" == "resolution" ]; then
|
pascal@18237
|
309 [ $res_max -lt $1 ] && res_max=$1
|
pascal@18237
|
310 [ $res_min -gt $1 ] && res_min=$1
|
pascal@18237
|
311 fi
|
pascal@18237
|
312 shift
|
pascal@18237
|
313 done
|
pascal@18237
|
314 echo "</select>"
|
pascal@18237
|
315 else
|
pascal@18237
|
316 [ "$(xPOST $name)" ] && def=$(xPOST $name)
|
pascal@18237
|
317 [ $def -lt $min ] && def=$min
|
pascal@18237
|
318 [ $def -gt $max ] && def=$max
|
pascal@20176
|
319 f="<fieldset><legend>$(_ "$name")</legend><input name=\"$name\" value=\"$def\""
|
pascal@18237
|
320 u=""
|
pascal@18237
|
321 case "$name" in
|
pascal@18237
|
322 x|y|l|t) cat <<EOT
|
pascal@18237
|
323 :${name}_max=$max
|
pascal@18237
|
324 <input type="hidden" name="${name}_min" value="$min">
|
pascal@18237
|
325 <input type="hidden" name="${name}_max" value="$max">
|
pascal@18237
|
326 EOT
|
pascal@18237
|
327 while read name2 n2 id val; do
|
pascal@18237
|
328 [ "$name" == "$name2" ] || continue
|
pascal@18237
|
329 [ "$(xPOST geometry_$name)" ] &&
|
pascal@18237
|
330 val="$(xPOST geometry_$name)"
|
pascal@18267
|
331 f="<fieldset><legend>$(_ "$n2")</legend><input name=\"geometry_$name\" id=\"$id\" value=\"$val\""
|
pascal@18237
|
332 u=" mm"
|
pascal@18237
|
333 break
|
pascal@18237
|
334 done <<EOT
|
pascal@18237
|
335 l X-Offset x 0
|
pascal@18237
|
336 t Y-Offset y 0
|
pascal@18237
|
337 x Width width $max
|
pascal@18237
|
338 y Height height $max
|
pascal@18237
|
339 EOT
|
pascal@18237
|
340 esac
|
pascal@18237
|
341 [ "$name" == "resolution" ] && f="$f onchange=showGeometry()"
|
pascal@18237
|
342 echo "<td>$f type=\"text\" title=\"$min .. $max\" size=4 maxlength=4>$u"
|
pascal@18237
|
343 res_min=$min
|
pascal@18237
|
344 res_max=$max
|
pascal@18237
|
345 fi
|
pascal@18237
|
346 case "$name" in
|
pascal@18237
|
347 resolution) cat <<EOT
|
pascal@18237
|
348 <input type="hidden" name="res_min" value="$res_min">
|
pascal@18237
|
349 <input type="hidden" name="res_max" value="$res_max">
|
pascal@18237
|
350 dpi
|
pascal@18237
|
351 EOT
|
pascal@18237
|
352 esac
|
pascal@18267
|
353 echo "</filedset></td>"
|
pascal@18242
|
354 n=$(($n - 2))
|
pascal@18242
|
355 case "$n" in
|
pascal@18242
|
356 1|2) echo "</tr><tr>"
|
pascal@18242
|
357 esac
|
pascal@18237
|
358 done)"
|
pascal@18237
|
359 echo "$output" | sed '/^:/d'
|
pascal@18237
|
360
|
pascal@18237
|
361 org_x=$(xPOST geometry_x); [ "$org_x" ] || org_x=$(echo "$output" | sed '/^:x_max=/!d;s/.*=//')
|
pascal@18237
|
362 org_y=$(xPOST geometry_y); [ "$org_y" ] || org_y=$(echo "$output" | sed '/^:y_max=/!d;s/.*=//')
|
pascal@18237
|
363
|
pascal@18237
|
364 cat <<EOT
|
pascal@18237
|
365 </tr>
|
pascal@18237
|
366 </table>
|
pascal@18237
|
367 <input type="hidden" name="tmpreview" value="$tmpreview">
|
pascal@18237
|
368 <input type="hidden" name="device" value="$device">
|
pascal@18237
|
369 <input type="hidden" name="params" value="$(echo "$params" | uuencode -m -)">
|
pascal@18237
|
370 <script language="JavaScript" type="text/javascript">
|
pascal@18237
|
371 <!--
|
pascal@18237
|
372 function setGeometry(x,y) {
|
pascal@18237
|
373 document.parameters.geometry_x.value = x;
|
pascal@18237
|
374 document.parameters.geometry_y.value = y;
|
pascal@18237
|
375 cropSetFrameByInput();
|
pascal@18237
|
376 }
|
pascal@18237
|
377
|
pascal@18237
|
378 function showGeometry() {
|
pascal@18237
|
379 var resolution = document.parameters.resolution.value;
|
pascal@18237
|
380 if (resolution) {
|
pascal@18237
|
381 resolution /= 25.4;
|
pascal@18237
|
382 var x = Math.floor(document.parameters.geometry_x.value * resolution);
|
pascal@18237
|
383 var y = Math.floor(document.parameters.geometry_y.value * resolution);
|
pascal@18237
|
384 alert((Math.round(x * y / 100000)/10) + ' Mpixels\n' + x + 'x' + y);
|
pascal@18237
|
385 }
|
pascal@18237
|
386 }
|
pascal@18237
|
387 -->
|
pascal@18237
|
388 </script>
|
pascal@18237
|
389
|
pascal@18237
|
390 <footer align="center">
|
pascal@18237
|
391 EOT
|
pascal@18237
|
392 awk -vox=$org_x -voy=$org_y 'END {
|
pascal@18237
|
393 x=210*4; y=297*4; n=0; cnt=0;
|
pascal@18237
|
394 while (cnt < 9) {
|
pascal@18237
|
395 if (ox +1 >= x && oy +1 >= y) {
|
pascal@18237
|
396 print " <a href=\"javascript:setGeometry(" x "," y ")\">DIN-A" n "</a>"
|
pascal@18237
|
397 cnt++
|
pascal@18237
|
398 }
|
pascal@18237
|
399 if (ox +1 >= x && oy +1 >= y) {
|
pascal@18237
|
400 print " <a href=\"javascript:setGeometry(" y "," x ")\">DIN-A" n "L</a>"
|
pascal@18237
|
401 cnt++
|
pascal@18237
|
402 }
|
pascal@18237
|
403 tmp=x; x=y/2; y=tmp
|
pascal@18237
|
404 n++
|
pascal@18237
|
405 }
|
pascal@18237
|
406 }' < /dev/null
|
pascal@18237
|
407
|
pascal@18237
|
408 cat <<EOT
|
pascal@18237
|
409 </footer>
|
pascal@18237
|
410 </form>
|
pascal@18237
|
411 </section>
|
pascal@18237
|
412 EOT
|
pascal@18237
|
413
|
pascal@18237
|
414 [ -s "$tmpreview" ] && cat <<EOT
|
pascal@18237
|
415 <div margin="15px" style="overflow-x: auto">
|
pascal@18237
|
416 <script type="text/javascript" src="lib/crop.js"></script>
|
pascal@18237
|
417 <img src="$tmpreview" onload=cropInit(this,'x','y','width','height')>
|
pascal@18237
|
418 </div>
|
pascal@18237
|
419 EOT
|
pascal@18237
|
420 xhtml_footer
|