24 aug 2020 @ justine's web page

printimage.com

This is similar to the printvideo.com program but it only prints PNG/GIF/JPEG images. It's also more portable. Here's what lemurs look like in XTERM256 quant mode with Hilbert curve dithering and unsharp masking.

Surprisingly enough, the Windows Command Prompt actually supports 24-bit ANSI escape sequences these days.

There are a few esoteric flags for showing images at original size with rulers and subpixel layout for closer examination. The man page can be viewed as follows:

bash$ ./printimage.com -?
Usage: printimage.com [FLAGS] [PATH]

FLAGS

  -o PATH    output path
  -w INT     manual width
  -h INT     manual height
  -4         unicode blocks
  -a         ansi color mode
  -t         true color mode
  -2         use half blocks
  -3         ibm cp437 blocks
  -f         display full size
  -s         unsharp sharpening
  -x         xterm256 color mode
  -m         use magikarp scaling
  -d         hilbert curve dithering
  -r         display pixel ruler on sides
  -p         convert to subpixel layout
  -v         increases verbosity
  -?         shows this information

The αcτµαlly pδrταblε εxεcµταblε below is about 100kb and actually does run on multiple operating systems. While the finished product is tiny, the sources that went into creating it are nontrivial and only recommended reading if you really love printing lemurs in terminals.

If you'd rather have tiny code with a little less quality for easy vendoring of image printing into your existing apps, then check out out jart's printimage.c gist for an elegant barebones solution. Please note that it depends on the ImageMagick convert command being installed, whereas printimage.com uses a modified version of nothings/stb.

download   [Linux] [Windows] [MacOS] [FreeBSD] [OpenBSD] [NetBSD]

printimage.com (295k PE+ELF+MachO+ZIP+SH 2022-04-21)

source code

printimage.c
magikarp.c
gyarados.c
getintegercoefficients.c
differsumsq.c
ttyraster.c
dither.c
idct.c
illumination.sh
dinlerp.c

see also

printvideo.com (1)
hiptext (1)
hiptext-docker
justine's web page