pbmview/README.md

1.5 KiB

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).