#color #static #images

bin+lib dither

A ditherer for static images with a variety of color palettes

15 releases (9 stable)

✓ Uses Rust 2018 edition

1.2.0 Feb 13, 2019
1.1.1 Feb 12, 2019
0.3.3 Jan 31, 2019
0.2.1 Jan 30, 2019
Download history 52/week @ 2019-01-30 43/week @ 2019-02-06

38 downloads per month

MIT license

515KB
972 lines

Dither

Inspired by: http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code/

  • no dithering: bunny_no_dither
  • one_bit black and white floyd_steinberg dithering bunny_floyd_bw_1
  • CGA 16-color mode, sierra 3 dithering: bunny_sierra_cga

License: MIT

CLI help:

dither --help

usage

dither INPUT [OUTPUT] [-v] [--dither] [--color] [--depth]

example:

dither bunny.png green_bunny.png --dither=atkinson --color=GREEN --depth=2 -v

args

INPUT

the path to an input image. known good image formats are .png and .jpg.

OUTPUT

the path to write the output. this will create or truncate the file at the existing location, if necessary. the image type will be inferred from the filename. currently, only .png and .jpg are supported.

-c, --color

The color mode to use. Default is "bw" (black and white). Color mode to use.

"color"

(all colors with specified bit depth)

"bw"

black and white mode (grayscale in higher birt depths)

$COLOR

single-color mode. options are

  • BLUE
  • GREEN
  • CYAN
  • RED
  • MAGENTA
  • BROWN
  • LIGHT_GRAY
  • GRAY
  • LIGHT_BLUE
  • LIGHT_GREEN
  • LIGHT_CYAN "LIGHT_RED"
  • LIGHT_MAGENTA
  • YELLOW
  • WHITE

"$FRONT $BACK"

user specified 1bit user color palette, where the first is foreground in hexidecimal and the second is background. eg, "0xaabbcc 0x000000"

cga

sixteen-color CGA. ignores bit depth; casues error on bit depth > 1

-d, --dither

The type of ditherer to use. Available options are

  • "floyd", "steinberg", "floydsteinberg" (default, floyd-steinberg dithering)
  • "atkinson",
  • "stucki",
  • "burkes",
  • "jarvis", "judice", ninke" Jarvis-Judice-Ninke dithering
  • "sierra", "sierra3" Sierra dithering

-v, --verbose

Verbose debug output

--depth

Default 1. Bit depth should be an unsigned integer between 1 and 7. The number of bits to compress each channel to.

Dependencies

~5.5MB
~88K SLoC