Allow reading stdin/pipes as images
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 869
- Forks
- 106
- PR merge metrics
- No merged PRs in 30d
Description
## Requested feature
Support opening pipes, or at least stdin.
## Use case
I want to use drawing when I take a screen shot, basically like `screenshot | drawing -`, or `drawing <(screenshot)`.
This avoids needing to store a temporary file, and makes the flow simpler: only explicitly saved screen shots are ever stored. This happens a fair amount because my `screenshot` commands includes a step where I select a part of the screen with my mouse, which I often decide I want to redo.
## How to test
You can replace `screenshot` in the above examples with `cat /path/to/image`.
## Implementation idea
I think the best would be to detect if a given file is a pipe, read it and try to create a `DrImage` with the bytes.
`DrImage` would need to be adapted to also support using bytes instead of a `gfile`, so no file watching and create a pixbuf from bytes with: [GdkPixbuf.Pixbuf.new_from_bytes](https://docs.gtk.org/gdk-pixbuf/ctor.Pixbuf.new_from_bytes.html).
In the case the read bytes are not an image you'll need to display an error window, but that could also help fix the TODO in `_get_valid_file`: remove the `utilities_gfile_is_image` check and in the `DrImage` the pixbuf will give you an exception you display.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing image opening through _get_valid_file, utilities_gfile_is_image, and DrImage, then review the suggested GdkPixbuf.Pixbuf.new_from_bytes API. Test with cat /path/to/image piped to the application and verify that valid image bytes open without a temporary file while invalid bytes produce an error window.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100