Programster's Blog

Tutorials focusing on Linux, programming, and open-source

HP Scan Cheatsheet

If you have an HP printer (which have great Linux support), and you have installed the hplip tool, you will have access to the hp-scan tool, which will trigger a scanning job of your printer.

By default, the tool will scan quickly in greyscale to a file called hpscanXXX.png where XXX are a set of numbers to give a unique value.

I prefer to output in color, and a .jpg file instead, so the command I would use most frequently is:

hp-scan \
  --mode=color \
  --size=a4 \
  --compression=jpeg

If you want it in grayscale, then you can do the following, but such a mode will not allow saving as a .jpg file.

hp-scan --mode=gray

Specify Output File

If you wish to specify where the file should be saved to, just add the --output flag like so:

hp-scan \
  --mode=color \
  --compression=jpeg \
  --output=my-file.jpg

Of course there is shorthand too:

hp-scan -m=color -x=jpeg -o=my-file.jpg

Emailing

If you want to send the image in an email, use the following:

hp-scan \
  --mode=color \
  --compression=jpeg \
  ---email-from=my-email@gmail.com \
  --email-subject="subject here" \
  --email-msg="Your scan is attached" \
  --email-to="an-email@gmail.com" 

I am guessing that this will have the printer send the email using any SMTP credentials it has been configured with, rather than trying to send the email from your computer, but I may be wrong.

References

Last updated: 10th March 2022
First published: 30th June 2021