A terminal based netpbm image viewer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sloum 120d0dd63e Fixes fit resizing smaller images and adds comments about broken scaling 2 months ago
examples Fixes fit resizing smaller images and adds comments about broken scaling 2 months ago
termios Adds working terminal viewer for pbm docs of type P1, P2, and P3 with available scaling 2 months ago
.gitignore Adds working terminal viewer for pbm docs of type P1, P2, and P3 with available scaling 2 months ago
LICENSE Adds simple readme and license 2 months ago
README.md Adds readme text 2 months ago
main.go Fixes fit resizing smaller images and adds comments about broken scaling 2 months ago

README.md

pbmview

pbmview is a program, written in golang, to display netpbm images in a terminal. This likely exists as a part of the very large netpbm package many operating systems/distros make available in their repositories... but it was fun to work on.

At present pbmview supports: P1, P2, and P3 images (all of the human readable ASCII file types). Support may get added at a later point for types > P3 (binary types). The ascii types are fun to use to create little icons that can be used in shell scripts or the like. The fact that they are human readable make them a cool format for sharing over gopher/gemini as plain text. This formatting, being ascii based, will result in a larger image size than a jpg/png/etc in most cases, so if you decide to use it I recommend doing so for its ease of programming/scripting and for its ease of human readability.

Build and Use

If you have a golang compiler you should be able to compile the program (likely with go build or go install) and run it as follows:

pbmview [flags] [path to pbm/pgm/ppm]

The available flags are:

  • -fit - Will shrink the image to the terminal width. If the image width is already smaller than the terminal, it will just display it.
  • -scale [chars] - Will scale the image to a width equal to chars, where chars represents a pixel width in terminal characters.
  • -h - Print help text and exit

Examples netpbm images are provided in the examples folder (which contains its own readme for attribution purposes).