20

I want to be able to scan from the terminal and then send the scanned output to a specific directory. Can this be done from the terminal.

3 Answers 3

26

scanimage is installed by default.

And here's me using it:

$ scanimage -L
device `epson2:libusb:002:003' is a Epson PID 084F flatbed scanner

$ scanimage -d "epson2:libusb:002:003" --format tiff > rawr.tiff

Obviously that generates a tiff-formatted file. Lossless but usually quite vast. You can convert this down withou an intermediary file by installing imagemagick and then piping the scan output into the convert command:

$ scanimage -d "epson2:libusb:002:003" --format=tiff | convert tiff:- scan.jpg
3
  • Can I save the file as JPEG? man scanimage just says I can use pnm or tiff with --format. Neither of these are what I want and both are producing incredibly large files (25 MB!) Sep 17, 2017 at 17:53
  • 1
    You can convert them with convert command in the imagemagick package. I'll update the answer.
    – Oli
    Sep 17, 2017 at 20:38
  • Modern scanimage supports png and jpeg natively, no imagemagick required (which is nice)
    – LovesTha
    Dec 27, 2018 at 5:51
4

Tested in 18.04 LTS, works fine.

You may need to set a scan resolution (150/300/600 dpi). To do this use "--resolution" param (this param don't mentioned in scanimage manpage docs). It helps you to reduce the size of produced files.

Example for 600 dpi scan with png output:

scanimage "epson2:libusb:002:003" --resolution 600 --format=png

Output file size difference between 300 and 600 dpi is significant if you scan an image (not text).

My values for default A4 image:

  • 300 dpi: 2560px * 3150px image, 2-20 Mb *.png file
  • 600 dpi: 5120px * 7020px image, 30-65 Mb *.png file
1
  • In order to avoid the error scanimage: argument without option: 'epson2:libusb:002:003'; try scanimage --help you need to add -d or --device-name= before the device identifier Jan 7, 2023 at 3:36
1

Here's a simple command line tool I wrote for myself to scan documents, uses scanimage and imagemagic to scan:

https://github.com/pohape/command-line-scanner

To get a JPEG file with the scan result:

./scan.sh ./test.jpg

To get a PNG file with the scan result:

./scan.sh ./test.png

To get a PDF file with the scan result:

./scan.sh ./test.pdf

2
  • Welcome to Ask Ubuntu and thank you for your answer! It seems that you are the author of the tool in your answer, so can you please edit it to disclose your affiliation with the project? See this post from the Help Center: How to not be a spammer Dec 2, 2022 at 16:44
  • @BeastOfCaerbannog done =) Dec 3, 2022 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .