Available Functions

scanline_wrapper.list_scanners(browsesecs=1, verbose=False)

Get a list of available scanners.

Example:

>>> import scanline_wrapper
>>> scanline_wrapper.list_scanners()
... ['HP Color LaserJet MFP M281fdw (035F4A)', 'My other scanner']
Parameters:
  • browsesecs (int) – Specify how long to wait when searching for scanners (in seconds, default: 1).

  • verbose (bool) – Increase verbosity of scanline logs (default: False).

Raises:
  • ScanlineExecutableNotFound – if the scanline app is not installed.

  • subprocess.CalledProcessError – if something goes wrong while running the scanline command.

Return type:

list(str)

Returns:

the available scanners.

scanline_wrapper.scan_flatbed(output_path, scanner=None, is_scanner_exact_name=False, page_size=PageSize.A4, file_format=FileFormat.AUTO, color=Color.COLOR, resolution=150, browsesecs=1, verbose=False)

Scans a document using the flatbed unit of the scanner.

Simple example:

>>> import scanline_wrapper
>>> scanline_wrapper.scan_flatbed("./out.tiff")

More complete example:

>>> import scanline_wrapper
>>> scanline_wrapper.scan_flatbed(
>>>     "./out.jpg",
>>>     scanner="HP Color LaserJet MFP M281fdw (035F4A)",
>>>     page_size=scanline_wrapper.PageSize.LETTER,        # A4, LEGAL or LETTER
>>>     file_format=scanline_wrapper.FileFormat.JPEG,      # AUTO, PDF, TIFF or JPEG
>>>     color=scanline_wrapper.Color.COLOR,                # COLOR or MONOCHROME
>>>     resolution=150,                                    # DPI
>>> )
Parameters:
  • output_path (str,pathlib.Path) – The output file path.

  • scanner (str) – The name of the scanner to use. If not provided, the first available scanner will be used (default: None).

  • is_scanner_exact_name (bool) – If set to True, scanline will try to fuzzy-match the scanner name (default: False).

  • page_size (PageSize) – The size of the page to scan (default. PageSize.A4).

  • file_format (FileFormat) – The output file format. If set to FileFormat.AUTO the format will be infered from the file extension. A ValueError will be raised if the file extension does not match a supported format. (default: FileFormat.AUTO).

  • color (Color) – Select color or monochrome scan (default: Color.COLOR).

  • resolution (int) – Specify minimum resolution at which to scan (in dpi, default: 150).

  • browsesecs (int) – Specify how long to wait when searching for scanners (in seconds, default: 1).

  • verbose (bool) – Increase verbosity of scanline logs (default: False).

Raises:
Return type:

None