# Scanner

# 1 LiDE 35

USB flatbed scanner, a few mm above A4 size. lsusb says:

ID 04a9:2213 Canon, Inc. CanoScan LiDE 50/LiDE 35/LiDE 40

Uses genesys sane backend.

SANE is the system to access scanners on Linux.

Debian Trixie has a regression in sane-backends (upstream problem):

Supported modes Gray (default), Color.

Supported bit depth: 8 (default), 16

Supported DPI (time to scan A4 page as 8bit RGB, size of output PPM):

  • 2400 (381s, 1600M)
  • 1200 (207s, 400M)
  • 600 (73s, 100M)
  • 300 (51s, 25M)
  • 200 (43s, 12M)
  • 150 (40s, 6.3M)
  • 75 (37s, 1.6M)

Gray takes the same time as RGB but output PGM are 3x smaller.

16bit depth takes the same time but output files are 2x bigger.

# 1.1 Buttons

scanbd is a daemon that polls scanner buttons and proxies scanner access to saned.

It was a struggle to get working. Tips on:

Ignore the step

copy all configuration files from /etc/sane.d/ to /etc/scanbd/sane.d/ (these will be needed later):

because this is done automatically by the Debian package.

/etc/sane.d/dll.conf should contain just net; when proxied by scanbd sane uses /etc/scanbd/dll.conf which should contain the scanner backend (in my case, genesys).

/etc/sane.d/net.conf should contain:

connect_timeout = 5
localhost
[::]

Forcing systemd to use IPv4 (with ListenStream=address:port) instead of IPv6 (default with just ListenStream=port) helped:

$ grep 6566 /etc/systemd/system/sockets.target.wants/scanbm.socket 
ListenStream=127.0.0.1:6566

/etc/inetd.conf should contain:

sane-port stream tcp nowait scanbd.scanner /usr/sbin/scanbm scanbm
sane-port stream tcp6 nowait scanbd.scanner /usr/sbin/scanbm scanbm

Here’s my /etc/scanbd/scripts/test.script, which scans A4 at 300dpi RGB (25MB PPM), then makes a 100dpi processed PNG suitable for text documents (typically ~200kB), putting both files (timestamp in filename) in ~/Scans/:

#!/bin/sh
if [ "x${SCANBD_ACTION}" = "xcopy" ]
then
  STEM="/home/claude/Scans/$(date --iso=s | tr ":" "-")"
  scanimage -d "${SCANBD_DEVICE}" --mode Color --resolution 300 -x 210 -y 297 --format=pnm --output-file="${STEM}-300dpi.ppm"
  convert "${STEM}-300dpi.ppm" -colorspace RGB -posterize 2 -resize "33.333333333333333%" -density 100x100 -colorspace sRGB "${STEM}-100dpi.png"
else
  env
fi

/etc/scanbd/scripts/copy.script is a symlink to the test.script.

SCANBD_ACTION will be one of (left to right on scanner):

  • copy
  • scan
  • file
  • email

The Scans folder has write permissions for the scanner group, set with chown claude:scanner:

$ ls -lad /home/claude/Scans
drwxrwxr-x 2 claude scanner 4096 Nov 19 13:29 /home/claude/Scans