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