naelstrof / maim

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
Other
2.13k stars 78 forks source link

Image corruption #265

Closed 0Karakurt0 closed 1 year ago

0Karakurt0 commented 1 year ago

"Streamed" trough pipe image gets corrupted along the way

feh WARNING: 2022-10-18_02:09:38.png - Does not look like an image (magic bytes missing)
feh: No loadable images specified.
See 'feh --help' or 'man feh' for detailed usage information

Example code

 { cat ~/pipe.tmp |\
   tee ~/Images/Screenshots/$(date +%F_%T).png |\
   xclip -selection clipboard -t image/png
 } &
 maim -s -k - > ~/pipe.tmp  

switching to scrot -s - > ~/pipe.tmp helps, therefore it's maim's bug.

foxpy commented 1 year ago

I currently don't have a machine with X11 setup so I cannot test this.

But that's really weird, maim doesn't have different code for saving into file or piping. Could you try piping into file - and reading what it says? Should be something like "PNG image RGBwhatever XxY pixels". Otherwise that's really a bug in maim.

0Karakurt0 commented 1 year ago

~ ➜ cat pipe.tmp | file - /dev/stdin: empty ~ ➜

foxpy commented 1 year ago

/dev/stdin: empty

There is just no data! Are you sure that maim -s -k - > ~/pipe.tmp actually writes any output?

foxpy commented 1 year ago

I suspect maim doesn't support - syntax to write to stdout and instead creates file called - and writes PNG data into it? Can you try doing just maim -s -k > ~/pipe.tmp?

0Karakurt0 commented 1 year ago

That's it! And I was wondering who the hell spams ~/- me.

Well, I think this should be adjusted to be in line with other unix utilities

foxpy commented 1 year ago

Well, I think this should be adjusted to be in line with other unix utilities

I definitely agree with you.