Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display an image from the Linux console

I've created a minimal Linux system which boots to the console and does not contain any kind of graphical environment.

I now want to display an image file from my C program or a bash script on the screen.

How can I do this?

like image 342
mythbu Avatar asked Sep 02 '16 10:09

mythbu


People also ask

How do you display something in Linux?

The simplest way to view text files in Linux is the cat command. It displays the complete contents in the command line without using inputs to scroll through it. Here is an example of using the cat command to view the Linux version by displaying the contents of the /proc/version file.

How do I open a png file in Linux terminal?

For terminal users, feh is a great tool to view PNG files. It is a lightweight and straightforward tool that uses command-line arguments. Feh will launch the image and window size respective to the image size. To control image display and how the tool works, consider the feh manual pages.


2 Answers

If your system has a framebuffer device, i.e. /dev/fb0, then there's the fbv framebuffer viewer utility for JPEG, GIF, PNG, and BMP images. (It's available as a target package in Buildroot.)
And if you have a suitable raw image (e.g. a framebuffer capture), then that file can be written directly to the framebuffer device.
See Super fast Linux splashscreen for more details.

like image 141
sawdust Avatar answered Sep 22 '22 15:09

sawdust


There are a few options.

  • If you have no “graphics” hardware, per se, you can use something like libaa or libcaca to convert an image into “ASCII ART.”
  • If you have PC-type VGA-type hardware available (at least), you can use something like svgalib to write to the hardware, eg, using zgv
  • If your device has a video framebuffer, you can write directly to the framebuffer device, as well.
like image 24
BRPocock Avatar answered Sep 24 '22 15:09

BRPocock