# HG changeset patch # User Pascal Bellard # Date 1438182444 -7200 # Node ID 1ed620c5ee23fd34f86ea787ee656b909567260e # Parent f630a53bd7137728a8525bb78254dcbb4a94640d sane-backends/sane.cgi: resize to screen width in preview diff -r f630a53bd713 -r 1ed620c5ee23 sane-backends/receipt --- a/sane-backends/receipt Tue Jul 28 10:56:38 2015 +0000 +++ b/sane-backends/receipt Wed Jul 29 17:07:24 2015 +0200 @@ -40,6 +40,7 @@ mkdir -p $fs/usr/lib $fs/usr/share \ $fs/var/lock/sane $fs/etc/sane.d \ $fs/var/www/tazpanel/lib \ + $fs/var/www/tazpanel/report.d \ $fs/var/www/tazpanel/menu.d/hardware cp -a $install/etc/sane.d $fs/etc @@ -49,6 +50,7 @@ cp -a $install/usr/lib/sane $fs/usr/lib cp -a $install/usr/share/sane $fs/usr/share cp $stuff/tazpanel/sane.cgi $fs/var/www/tazpanel/ + cp $stuff/tazpanel/sane $fs/var/www/tazpanel/report.d/ cp $stuff/tazpanel/crop.js $fs/var/www/tazpanel/lib/ ln -s ../../sane.cgi $fs/var/www/tazpanel/menu.d/hardware/sane diff -r f630a53bd713 -r 1ed620c5ee23 sane-backends/stuff/tazpanel/sane --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sane-backends/stuff/tazpanel/sane Wed Jul 29 17:07:24 2015 +0200 @@ -0,0 +1,5 @@ + cat <scanimage --help +
$(scanimage --help 2>&1)
+ +EOT diff -r f630a53bd713 -r 1ed620c5ee23 sane-backends/stuff/tazpanel/sane.cgi --- a/sane-backends/stuff/tazpanel/sane.cgi Tue Jul 28 10:56:38 2015 +0000 +++ b/sane-backends/stuff/tazpanel/sane.cgi Wed Jul 29 17:07:24 2015 +0200 @@ -37,11 +37,12 @@ getgeometry() { CMD="" - for i in l t x y ; do + ARGS="" + for i in x y l t ; do j=$(inrange $(xPOST geometry_$i) $(xPOST ${i}_min) $(xPOST ${i}_max)) eval "geometry_$i=$j" CMD="$CMD -$i $j" -# convert -crop XxY+L+T -resize XxY + ARGS="$ARGS $j" done for i in mode source contrast brightness ; do [ "$(xPOST $i)" ] && CMD="$CMD --$i '$(xPOST $i)'" @@ -55,10 +56,35 @@ resolution=$(($resolution * 2)) done fi + case "$(xPOST mode)" in + *lack*|*ineart*) mode="-monochrome" ;; + *ray*) mode="-colorspace gray" ;; + *) mode="" ;; + esac [ -d tmp ] || ln -s /tmp tmp case "$device" in - fake*) echo "cat /usr/share/images/slitaz-background.jpg" ;; - *) echo "scanimage -d '$(echo $device | sed 's/,.*//')' --resolution '$(inrange $resolution $(xPOST res_min) $(xPOST res_max))dpi'$CMD" + fake*) f=/usr/share/images/slitaz-banner.png + c="$(echo $ARGS $(identify $f | sed \ + 's/.* \([0-9]*\)x.*/\1/') $(GET width) $(POST x_max) | awk ' +function a(x) { return int(($x * $5)/ $7); } +{ printf "%dx%d+%d+%d -resize %dx%d",a(1),a(2),a(3),a(4),$6,int(($2*$6)/$1)} +')" + cat < /dev/null ; then + cat /tmp/sane$$.png + rm -f /tmp/sane$$.png +else + cat $f +fi +EOT + ;; + *) echo -n "scanimage -d '$(echo $device | sed 's/,.*//')' --resolution '$(inrange $resolution $(xPOST res_min) $(xPOST res_max))dpi'$CMD" + if [ -z "$1" -a "$(which convert)" ]; then + echo -n "> /tmp/sane$$.pnm ; convert -resize " + echo $ARGS $(GET width) | awk '{ printf "%dx%d",$5,int(($2*$5)/$1)}' + echo -n " /tmp/sane$$.pnm /tmp/sane$$.png ;" + echo -n "cat /tmp/sane$$.png ; rm -f /tmp/sane$$.pn?" + fi esac } @@ -151,20 +177,31 @@ xhtml_header [ -n "$error" ] && msg warn "$error" [ -n "$info" ] && msg tip "$info" -[ "$(which convert 2> /dev/null)" ] || -msg tip "$(_ "You should install %s to preview images." \ - "imagemagick")" if [ -z "$device" ]; then - [ -s sane-fake.log ] && all="$(sed 's/|/\n/g' sane-fake.log)" || - all="$(scanimage -f '%d,%v %m|' | sed 's/|/\n/g')" + all="$(scanimage -f '%d,%v %m|'|cat - sane-fake.log|sed 's/|/\n/g')" case "$(echo "$all" | wc -l)" in 1) if [ -z "$all" ]; then - msg warn 'No scanner found' + msg warn "$(_ "No scanner found")" + msg tip "$(_ "You can test this GUI with ")\ +fake-sane" xhtml_footer exit 0 fi device="${all%|}" ;; - *) cat < /dev/null)" ] && continue + suggested="$suggested +
  • $pkg $msg
  • " + done <$suggested" + cat <
    @@ -190,7 +227,7 @@