TIFFMEDIAN(1)

πŸ’– TIFFMEDIAN πŸ’–

okay bestie, welcome to tiffmedian β€” it's a LibTIFF page and it is, no cap, the moment your RGB image gets a glow-down into a cute lil palette ✨


✨ NAME ✨

tiffmedian β€” apply the median cut algorithm to data in a TIFF file 🎨


🌸 SYNOPSIS 🌸

tiffmedian [ options ] input.tif output.tif

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: tiffmedian takes an RGB image in input.tif, runs the median cut algorithm on it, and pops out a palette image written to output.tif. Iconic behaviour, honestly.

The generated colormap has 256 entries by default β€” yes, all of them, we're not being shy πŸ’…

And how does the quantizing happen? Every pixel gets mapped to the closest color values in the colormap. That's it, that's the whole glow-up. Periodt. πŸ’–


πŸ’… OPTIONS πŸ’…

  • -c β€” tell it what compression to use for the data written to the output file. Your menu is: -c none for no compression at all, -c packbits for PackBits compression, -c lzw for Lempel-Ziv & Welch compression, and -c zip for Deflate compression. πŸ—œοΈ

By default, tiffmedian will compress data according to whatever the value of the Compression tag in the source file says. Respecting the original's choices, we love that for it 🫢

Now, LZW compression can be specified together with a predictor value, and this is the part where you lock in πŸ”₯ A predictor value of 2 causes each scanline of the output image to undergo horizontal differencing before it gets encoded; a value of 1 forces each scanline to be encoded without differencing. LZW-specific options get specified by appending a :-separated list to the lzw option β€” like, for example, -c lzw:2 for LZW compression with horizontal differencing. See? Cute AND precise ✨

  • -C β€” specify the number of entries to use in the generated colormap. (Capital C, bestie, do not confuse her with lowercase -c up there, they are two different girlies πŸ’€) By default all 256 entries/colors are used. 🌈
  • -f β€” apply Floyd-Steinberg dithering before selecting a colormap entry. Dithering before, not after. Okay? Okay πŸ’–
  • -r β€” specify the number of rows (scanlines) in each strip of data written to the output file. By default, tiffmedian attempts to set the rows/strip so that no more than 8 kilobytes of data appear in a strip. Very considerate of it, honestly πŸ‘‘

πŸ“ NOTES πŸ“

This program is derived from Paul Heckbert's median program. Giving credit where credit is due, as we should πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

  • pal2rgb (1)
  • tiffinfo (1)
  • tiffcp (1)
  • tiffcmp (1)
  • libtiff (3tiff),

And also this absolute classic of a paper, if you wanna go full academic main character energy πŸ“š:

  • "Color Image Quantization for Frame Buffer Display", Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307.

πŸ‘‘ AUTHOR πŸ‘‘

LibTIFF contributors πŸ’–


1988-2025, LibTIFF contributors


okay that's the whole page bestie, go forth and quantize responsibly 🌸

Version 4.7, dated Jun 27, 2026 β€” mwah, ty for reading, ily, bye πŸ’‹βœ¨πŸ¦‹

πŸ“¦ where this page comes from