python-pillow / python-pillow/Sane

Allow to get the raw image data without going over PIL.Image or NumPy

Open Beginner friendly
#110 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
61
Forks
22
PR merge metrics
No merged PRs in 30d

Description

So far there are two officially documented ways of getting image data after scanning: PIL.Image or NumPy array.

They both have their downsides. To only name one per package, PIL.Image lacks 48bit color support which limits all scans to only 24bit and a NumPy array is no image format. To get the data into something with proper image handling support (like a GdkPixbuf) this would have to be converted back to raw bytes, which makes the intermediate NumPy array useless.

Especially as both, PIL and NumPy, are optional dependencies, which are not enforced to use Python SANE, it would be nice to have some basic way to do a scan if neither PIL or NumPy are installed.

I'm currently developing a GUI scanning application in Python using the module, developed here. To do my scanning, I'll use "dev.snap()" which somewhat feels like an "undocumented internal function" but it does exactly what I need.

What I'm asking for is if it would be an useful addition to this module to expose "dev.snap()" in "sane.py" as "raw_snap" and add a convenience method "raw_scan" which, like the other "scan" methods, will call "start()" before calling "raw_snap". If so, I could prepare a Pull Request for this. I will keep using "dev.snap()" in the mean time as there is no useful alternative for now.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sane.py with the existing dev.snap() implementation and the other scan methods that call start(). Expose the raw snapshot data without requiring PIL or NumPy, and add raw_scan with the same start-before-capture behavior. Done means callers can obtain raw scan bytes through the public API without either optional dependency.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.