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 colour, and a jpg file instead, so the command I would use most frequently is:

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

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: 30th June 2021
First published: 30th June 2021