Hi everybody,
I am looking for a python library that could display image from a Linux terminal ? I mean without starting the XWindows interface. Does anyone hear about something that can do that ?
Thanks for your help
If your Linux system has support for the frame buffer interface, you can
call that with the path to the image.
Try installing “fbi” or perhaps “fbida” (on Fedora) using your OS
package manager, e.g. I ran:
sudo dnf install fbida
This is not a Python library, it is a system application, so you will
need to call it as an external process.
os.system('fbi path/to/myfile.jpg')
Thanks Steven for your reply, I think I must be more precise regarding my question.
I am working on Raspbian distribution and my image are numpy array capture from Webcam (Unicam). So images are not saved in file, but manipulate in memory through numpy array. So using a shell command is not possible. I could of course save the numpy array to a file and then use your command, but it will be too slow.
I know that opencv, PIL or other python libraries can display the pictures, but it needs to run under XWindows environment, not from terminal.
How can you be sure it’ll be too slow if you haven’t tried?
Either way thanks to Stephen’s answer you now know what to Google for.
From a quick search for “frame buffer linux python” it looks like writing directly to the frame buffer device from Python and using pygame/SDL are two viable options.
You’re right Thomas, that’s a good way to find the solution. Thank you both.
You don’t need to use the frame buffer. Modern terminals have remarkably
flexible character displays - there’s a library for rendering images as
coloured text/blocks on a character terminal. […] Ah, yes, aalib and
friends. See this stackoverflow post, it has several references:
https://unix.stackexchange.com/questions/117936/options-to-show-images-when-on-the-console
There’s at least one aalib module on PyPI which I’d expect you coud use
it to render a Image from PIL/Pillow.
Better still, some terminal emulators support real image display inline.
I’m using iTerm on a Mac. If I were sshed into the raspberry I could
dump the image to the terminal - there’s an escape sequence - you send
it then some base64 data containing the image data.
Cheers,
Cameron Simpson cs@cskk.id.au