joukos / PaperTTY

PaperTTY - Python module to render a TTY or VNC on e-ink
953 stars 104 forks source link

Add CLI sub-command to display image #54

Closed colin-nolan closed 4 years ago

colin-nolan commented 4 years ago

This PR adds an option to display an image from the CLI, similarly to how text can be displayed.

My main motivation for adding this functionality is to easily draw something to screen (that's more interesting than just text!) when looking into the drivers. It's also enables someone only interested in rendering images to easily benefit from this library.

The new image option allows an image (of any type Pillow can deal with) to be loaded from stdin or file path. The image will then be manipulated according to a couple of simple options, before been displayed.

joukos commented 4 years ago

It's actually a very nice command to have! I'll try it out too before merging. Besides being more exciting than text, it could also be used as a substitute for (the complexity of) VNC for some purposes, like periodically displaying a rendered web page with a cron job or so.

Actually, I currently have a sort of a prototype setup with the 7.5", mainly to test if there's any problems with long-term usage (none so far after 2+ months of operation). It displays an online weather map, and when putting it up I thought that it would be simpler to just download a fresh image periodically, overlay it with a timestamp and then draw it to the display, but PaperTTY lacked this command so I didn't bother then :) Maybe I'll change it after this gets merged, since running a browser in a VNC session is error-prone and unnecessarily complex for such a purpose.

Now that I think about it, I guess overlaying a message on the image could even be an optional argument for this command, since it's easy to do with Pillow and in many cases it might be useful to get a "last updated" timestamp or some other text in there to accompany the image. I'll try this out first and we'll see.

joukos commented 4 years ago

I tried it briefly now and seems to work great, it's very useful. The overlay text feature and such can be made later and I'll merge this now so it can be used. Thanks a lot!

joukos commented 4 years ago

I made a small addition to replace the --portrait option with --mirror (horizontal flip), --flip (vertical flip) and --rotation so that the image can be displayed in any orientation.

colin-nolan commented 4 years ago

Great, thanks a lot!