Linux: Scan An Image With HP Scanners

by on September 30, 2008 · 9 comments· LAST UPDATED September 30, 2008

in , ,

Q. I've HP all in one printer / scanner / fax machine installed and I'd love to scan an image using Linux command line or GUI application. How do I scan an image under Linux?

A. SANE (Scanner Access Now Easy) interface API that provides standardized access to any raster image scanner hardware (flatbed scanner, handheld scanner, video- and still-cameras, frame grabbers, etc.). You need to install sane software in order to access device using USB, LPT or network interface. There are various commands for scanning images under Linux:

a] scanimage - It is a command-line interface to control image acquisition devices such as flatbed scanners or cameras.

b] xscanimage / xsane - It provides a graphical user-interface to control an image acquisition device such as a flatbed scanner or a camera. It allows previewing and scanning invidual images and can be invoked either directly from the command-line or through The GIMP image manipulation program.

c] 3rd party Applications: GIMP or OpenOffice.Org and many other Linux application can acquire images using scanner if proper driver is installed.

d] Web interface: Many modern printers and scanners comes with web base tools to scan an image. All you have to do is fire a web browser > Type printer IP address and select Scan option. All scanned images can be viewed and downloaded from browser itself.

Install sane software

scanimage and xscanimage can be installed by typing following command:
$ sudo apt-get install sane sane-utils
Where,

  • sane-utils: API library for scanners -- utilities
  • sane: scanner graphical frontends including GIMP plugin

How do I find out if my scanner detected and driver is installed?

Simply type the following command at a shell prompt to get a list of devices:
$ scanimage -L
Sample Output:

device `hpaio:/net/Photosmart_C5100_series?ip=192.168.0.4' is a Hewlett-Packard Photosmart_C5100_series all-in-one
device `v4l:/dev/video0' is a Noname Pinnacle PCTV 40i/50i/110i (saa virtual device

How do I scan an image from a shell prompt?

To scan with default settings to the file scan-file.pnm, enter:
$ scanimage >scan-file.pnm
Note: You may need to add sudo command to get privileges to scan an image.
To scan 100x100 mm to the file image.tiff (-x and -y may not be available with all devices):
$ scanimage -x 100 -y 100 --format=tiff >old-photo.tiff
To scan with ADF (Auto Document Feeder), you must use "batch mode":
$ scanimage -b --batch-scan=yes > scanned-file.pnm

xsane: Graphical User Interface

Type xsane at a shell prompt:
$ xsane

Fig.01: xsane - Select Device

Fig.01: xsane - Select Device


Select your scanner and you will see main screen with tons of options:
Fig.02: XSane on My Ubuntu Linux Desktop

Fig.02: XSane on My Ubuntu Linux Desktop


Set options such as DPI, brightness etc and click on Scan button:
Fig.03: Sample image scanned with my HP scanner hardware

Fig.03: Sample image scanned with my HP scanner hardware

Other software such as GIMP and OpenOffice.org provides an option to scan and import images directly for editing purpose.

Under GIMP visit File > Acquire > XSane > Device Name to scan images.

Under OpenOffice.org wordprocessor visit Insert > Picture > Scan > Request... to scan images.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 9 comments… read them below or add one }

1 Francisco October 1, 2008 at 10:21 pm

Hey, I got a HP printer too, I had Ubuntu 8.04 but I am trying kubuntu 8.04 now, and it works great. My computer detected the scanner as soon I plugged it in, so I didn’t have any problems, in ubuntu I used xsane, now in kubuntu i use kooka, which is great too.

hope you solved your problem

Reply

2 mark March 3, 2011 at 3:34 am

This doesn’t work with HP Officejet products because the SANE find scanner will not look at parallel port devices. Scanner is switched on and printer works with hplip. Scanner works under Windows Me (not XP+) so it does work.

I would love for somebody to provide linux based solution to this that would provide a huge incentive for linux migration because of its full support of legacy hardware. My hardware is the HP Officejet r65 printer and scanner. It works well but needs WinMe to run the clunky scanner interface. Im hoping that linux can save us from that.

Im afraid that the only other option might be to install the windows device drivers under wine and hope for the best.

Reply

3 Orlando Hincapie August 22, 2011 at 9:03 pm

Using hp scanner 4070 in mode txt doesn’t work and show a message ORC file is not working or missing. Thank for your help

Reply

4 shylock_1 March 20, 2012 at 5:06 pm

Well Guys,
I have HP all-in-one 2050 scanner, printer and copier I used HP’s hplip-3.11.12 the entire installation require root login so I did all the installation under root. Now I can print and scan the document ONLY under Root privileges, rather than User.

IS somebody give me clue that print, usb drivers can allow me to access printer and scanner under ordinary user rather than login as root, please.
Thank you,
Sy

Reply

5 nixCraft March 20, 2012 at 5:42 pm

Under Linux and Unix like operating system you need to add user to lp group. This will take care of printing issue. For scanning issue add user to scanner group which is used by saned the SANE (Scanner Access Now Easy) daemon that allows remote clients to access image acquisition devices available on the local host. Check your /etc/passwd and /etc/group files for more info.

Reply

6 shylock_1 March 21, 2012 at 3:54 pm

Thank you for replying Vivek,

For printer there is lp group exists but
I cannot locate SANE group either in ps -A nor in the /etc/group file below are the all active demon currently running:
[code]
PID TTY TIME CMD
1 ? 00:00:00 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 migration/0
4 ? 00:00:00 ksoftirqd/0
5 ? 00:00:00 migration/0
6 ? 00:00:00 watchdog/0
7 ? 00:00:00 migration/1
8 ? 00:00:00 migration/1
9 ? 00:00:00 ksoftirqd/1
10 ? 00:00:00 watchdog/1
11 ? 00:00:00 events/0
12 ? 00:00:00 events/1
13 ? 00:00:00 cpuset
14 ? 00:00:00 khelper
15 ? 00:00:00 netns
16 ? 00:00:00 async/mgr
17 ? 00:00:00 pm
18 ? 00:00:00 sync_supers
19 ? 00:00:00 bdi-default
20 ? 00:00:00 kintegrityd/0
21 ? 00:00:00 kintegrityd/1
22 ? 00:00:00 kblockd/0
23 ? 00:00:00 kblockd/1
24 ? 00:00:00 kacpid
25 ? 00:00:00 kacpi_notify
26 ? 00:00:00 kacpi_hotplug
27 ? 00:00:00 ata/0
28 ? 00:00:00 ata/1
29 ? 00:00:00 ata_aux
30 ? 00:00:00 ksuspend_usbd
31 ? 00:00:00 khubd
32 ? 00:00:00 kseriod
33 ? 00:00:00 md/0
34 ? 00:00:00 md/1
35 ? 00:00:00 md_misc/0
36 ? 00:00:00 md_misc/1
37 ? 00:00:00 khungtaskd
38 ? 00:00:00 kswapd0
39 ? 00:00:00 ksmd
40 ? 00:00:00 aio/0
41 ? 00:00:00 aio/1
42 ? 00:00:00 crypto/0
43 ? 00:00:00 crypto/1
48 ? 00:00:00 kthrotld/0
49 ? 00:00:00 kthrotld/1
51 ? 00:00:00 kpsmoused
52 ? 00:00:00 usbhid_resumer
83 ? 00:00:00 kstriped
166 ? 00:00:00 i915
167 ? 00:00:00 kslowd000
168 ? 00:00:00 kslowd001
312 ? 00:00:00 scsi_eh_0
313 ? 00:00:00 scsi_eh_1
316 ? 00:00:00 scsi_eh_2
317 ? 00:00:00 scsi_eh_3
427 ? 00:00:00 kdmflush
431 ? 00:00:00 kdmflush
447 ? 00:00:00 jbd2/dm-0-8
448 ? 00:00:00 ext4-dio-unwrit
449 ? 00:00:00 ext4-dio-unwrit
539 ? 00:00:00 udevd
804 ? 00:00:00 hd-audio0
1022 ? 00:00:00 kdmflush
1063 ? 00:00:00 jbd2/sda1-8
1064 ? 00:00:00 ext4-dio-unwrit
1065 ? 00:00:00 ext4-dio-unwrit
1066 ? 00:00:00 jbd2/dm-2-8
1067 ? 00:00:00 ext4-dio-unwrit
1068 ? 00:00:00 ext4-dio-unwrit
1095 ? 00:00:00 flush-253:0
1096 ? 00:00:00 flush-253:2
1121 ? 00:00:00 kauditd
1366 ? 00:00:00 auditd
1391 ? 00:00:00 rsyslogd
1412 ? 00:00:00 cachefilesd
1457 ? 00:00:00 rpcbind
1538 ? 00:00:00 udevd
1575 ? 00:00:00 dbus-daemon
1586 ? 00:00:00 NetworkManager
1593 ? 00:00:00 modem-manager
1598 ? 00:00:00 avahi-daemon
1599 ? 00:00:00 avahi-daemon
1617 ? 00:00:00 dhclient
1619 ? 00:00:00 wpa_supplicant
1641 ? 00:00:00 named
1664 ? 00:00:00 rpc.statd
1701 ? 00:00:00 rpciod/0
1702 ? 00:00:00 rpciod/1
1709 ? 00:00:00 rpc.idmapd
1719 ? 00:00:00 cupsd
1789 ? 00:00:00 acpid
1803 ? 00:00:00 hald
1806 ? 00:00:00 hald-runner
1870 ? 00:00:00 hald-addon-inpu
1873 ? 00:00:00 hald-addon-acpi
1874 ? 00:00:00 hald-addon-stor
1901 ? 00:00:00 automount
1940 ? 00:00:00 rpc.rquotad
1943 ? 00:00:00 lockd
1944 ? 00:00:00 nfsd4
1945 ? 00:00:00 nfsd4_callbacks
1946 ? 00:00:00 nfsd
1947 ? 00:00:00 nfsd
1948 ? 00:00:00 nfsd
1949 ? 00:00:00 nfsd
1950 ? 00:00:00 nfsd
1951 ? 00:00:00 nfsd
1952 ? 00:00:00 nfsd
1953 ? 00:00:00 nfsd
1956 ? 00:00:00 rpc.mountd
2012 ? 00:00:00 snmpd
2023 ? 00:00:00 sshd
2031 ? 00:00:00 xinetd
2053 ? 00:00:00 ntpd
2090 ? 00:00:00 mysqld_safe
2284 ? 00:00:00 mysqld
2322 ? 00:00:00 ddclient
2401 ? 00:00:00 master
2410 ? 00:00:00 abrtd
2411 ? 00:00:00 pickup
2412 ? 00:00:00 qmgr
2428 ? 00:00:00 nss_pcache
2431 ? 00:00:00 httpd
2447 ? 00:00:00 crond
2458 ? 00:00:00 crlhelper
2461 ? 00:00:00 atd
2467 ? 00:00:00 httpd
2469 ? 00:00:00 httpd
2470 ? 00:00:00 httpd
2471 ? 00:00:00 httpd
2472 ? 00:00:00 httpd
2473 ? 00:00:00 httpd
2474 ? 00:00:00 httpd
2475 ? 00:00:00 httpd
2476 ? 00:00:00 httpd
2481 ? 00:00:00 libvirtd
2520 ? 00:00:00 udevd
2529 ? 00:00:00 rhsmcertd
2587 ? 00:00:00 gdm-binary
2598 tty2 00:00:00 mingetty
2601 tty3 00:00:00 mingetty
2604 tty4 00:00:00 mingetty
2606 tty5 00:00:00 mingetty
2608 tty6 00:00:00 mingetty
2610 ? 00:00:00 dnsmasq
2637 ? 00:00:00 gdm-simple-slav
2643 tty1 00:00:18 Xorg
2673 ? 00:00:00 console-kit-dae
2743 ? 00:00:00 dbus-launch
2749 ? 00:00:00 devkit-power-da
2792 ? 00:00:00 polkitd
2803 ? 00:00:00 rtkit-daemon
2806 ? 00:00:00 gdm-session-wor
2822 ? 00:00:00 gnome-keyring-d
2831 ? 00:00:00 gnome-session
2840 ? 00:00:00 dbus-launch
2841 ? 00:00:00 dbus-daemon
2916 ? 00:00:00 gconfd-2
2925 ? 00:00:00 gnome-settings-
2926 ? 00:00:00 seahorse-daemon
2933 ? 00:00:00 gvfsd
2939 ? 00:00:00 metacity
2943 ? 00:00:00 pulseaudio
2950 ? 00:00:00 gnome-panel
2960 ? 00:00:00 gconf-helper
2961 ? 00:00:03 nautilus
2963 ? 00:00:00 bonobo-activati
2971 ? 00:00:00 wnck-applet
2972 ? 00:00:00 trashapplet
2975 ? 00:00:00 gvfs-gdu-volume
2977 ? 00:00:00 gvfsd-trash
2979 ? 00:00:00 polkit-gnome-au
2981 ? 00:00:00 python
2985 ? 00:00:00 gpk-update-icon
2986 ? 00:00:00 gnome-power-man
2987 ? 00:00:00 bluetooth-apple
2988 ? 00:00:00 gdu-notificatio
2989 ? 00:00:00 python
2993 ? 00:00:00 udisks-daemon
2996 ? 00:00:00 udisks-daemon
2998 ? 00:00:00 rhsm-compliance
2999 ? 00:00:00 restorecond
3000 ? 00:00:00 rhythmbox
3005 ? 00:00:00 kwikdisk
3006 ? 00:00:00 gvfs-gphoto2-vo
3007 ? 00:00:00 gnome-terminal
3013 ? 00:00:00 python
3014 ? 00:00:00 python
3015 ? 00:00:00 nm-applet
3016 ? 00:00:00 gnome-volume-co
3017 ? 00:00:00 abrt-applet
3020 ? 00:00:00 gnome-user-shar
3028 ? 00:00:00 im-settings-dae
3033 ? 00:00:00 vino-server
3053 ? 00:00:00 gvfs-afc-volume
3150 ? 00:00:00 httpd
3151 ? 00:00:00 httpd
3152 ? 00:00:00 httpd
3156 ? 00:00:00 gnome-screensav
3193 ? 00:00:00 gconf-im-settin
3196 ? 00:00:00 gnome-pty-helpe
3197 pts/0 00:00:00 bash
3201 pts/1 00:00:00 bash
3228 ? 00:00:00 gnote
3235 ? 00:00:00 gdm-user-switch
3237 ? 00:00:00 notification-ar
3238 ? 00:00:00 clock-applet
3252 ? 00:00:00 gvfsd-burn
3265 ? 00:00:00 gvfsd-cdda
3291 pts/1 00:00:00 su
3299 pts/1 00:00:00 bash
3309 ? 00:00:54 firefox
3394 ? 00:00:25 npviewer.bin
3419 ? 00:00:00 npviewer.bin
3430 ? 00:00:00 GoogleTalkPlugi
3604 pts/1 00:00:00 ps
3605 pts/1 00:00:00 more
[/code]

Reply

7 mrG November 15, 2012 at 6:32 pm

Can I ask a more technical question? How can I chain scanimage and netpbm to simulate a copier?

I had this working, once upon a time, but upgrades in Ubuntu have broken it and I can’t figure out how to fix it. For example

scanimage –device ‘hpaio:/usb/psc_1310_series?serial=CN47LB80R8O2′ –resolution 300 –format pnm | pnmtojpeg | lpr

would just work, but now it prints the document 4x magnified across multiple pages!

scanimage –device ‘hpaio:/usb/psc_1310_series?serial=CN47LB80R8O2′ –resolution 300 –format pnm | lpr

strangely does the same thing, although I would have expected the 300dpi’s to match things perfectly.

if I pipe the output through pnmtops I get a complaint about the image being too large and being rescaled 0.225898 (!) but the image that results has now been reduced in size to fit within the postscript page, and the contrast is lost :(

Any ideas for a better recipe?

Reply

8 Shimon December 20, 2012 at 5:52 pm

Hi,
I have used xsane’s built in copier function with no problems. Did you try it and there is a problem, or you didn’t notice it?

All you need to do is, on the main xsane window, go to the drop down
list of options at the top right of the window (marked with a “bullseye”
symbol, for the “target” of your scan). Choose “Copy”, and the field with
output file name will disappear, replaced with printer information.
On the left, number of copies. On the right, which printer to copy to.

This worked very straightforward for me, without any of the difficulties you describe with the other programs.

Reply

9 linoskoczek September 24, 2013 at 7:00 pm

Helped me alot, now I use my printer completely under linux :)

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: