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