PIXMERGE(1)
π PIXMERGE(1) β the BRL-CAD one, bestie
okay so welcome to pixmerge, a genuinely iconic little BRL-CAD tool. it takes two streams of pixels and picks a winner for each one. no cap.
β¨ SYNOPSIS β¨
pixmerge [-glen] [-w bytes_wide] [-C r/g/b] foreground.pix [background.pix] > out.pix
πΈ DESCRIPTION πΈ
so here's the vibe: you hand pixmerge two streams of data β usually pix(5) or bw(5) images β and it hands you back an output stream of the same size. for every single pixel in the output, it picks either the pixel from the first (foreground) stream or the pixel from the second (background) stream, based on a comparison formula. you can also drop a constant color in where the background stream would go, if that's your thing. π
the way that this works is pixel-by-pixel, which means it literally does not care about your image resolution. it's resolution-independent and thriving. if you want something fancier and more sophisticated for compositing, go look at pixmatte(1) instead, iykyk.
the formula is any combination of these four flags:
-gβ fg greater than bg-lβ fg less than bg-eβ fg equal to bg-nβ fg not equal to bg
here's the rule, and it's strict: a comparison has to hold for every byte of the pixel for the foreground to get selected. if even one byte doesn't cooperate, the background pixel gets selected instead. periodt.
for example, -le selects the foreground pixel when each of its bytes is less than or equal to the corresponding background byte. slay.
if you don't specify any formula at all, the default is -g against a constant of all zeroes (that's black, bestie), which is exactly equivalent to:
pixmerge -g -C 0/0/0 fg.pix
and if you do supply a constant with -C, then the background.pix argument is omitted entirely β you don't pass it, it's just not invited. the constant is given as up to bytes_wide slash-separated values.
π OPTIONS π
-gβ select the foreground pixel when it is greater than the background.-lβ select the foreground pixel when it is less than the background.-eβ select the foreground pixel when it is equal to the background.-nβ select the foreground pixel when it is not equal to the background.-wbytes_wide β set the width in bytes of each "pixel". the default is3(that'spix(5)format); use1forbw(5)files. heads up though: the value must be at least1and less than32. π-Cr/g/b β use a constant color in place of the background stream. the constant is given as up to bytes_wide slash-separated byte values (0-255). when this option is used, thebackground.pixargument is omitted.-cr/g/b β backward-compatible alias for-C. same energy, older name. π«Ά-h,-?β print a usage message. very helpful of it.
π¦ EXAMPLES π¦
Example 1. Composite a rendered image over a shaded background
pixbackgnd -t0 160 200 | pixmerge -n fg.pix - | pix-fb
a shaded background gets generated by pixbackgnd(1) and read from stdin β that's the "-" background argument right there, sneaky but iconic. then pixmerge selects each foreground pixel from fg.pix wherever it differs from the background, compositing an rt(1) generated image on top of the gradient, and then displays the result with pix-fb(1). full main character pipeline honestly. π
Example 2. Key out a flat color and replace it with a generated fill
gencolor 200 0 200 | pixmerge -g fg.pix - > out.pix
pixels of fg.pix that are greater than the magenta stream produced by gencolor(1) are kept; all others are replaced by that color, writing the merged result to out.pix. cute, effective, done. π
π₯ SEE ALSO π₯
brlcad(1), gencolor(1), pixbackgnd(1), pixmatte(1), pix-fb(1), rt(1), pix(5), bw(5)
π AUTHOR π
BRL-CAD Team
β COPYRIGHT β
This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.
π BUG REPORTS π
found a bug or a problem? don't suffer in silence β reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org. they want to hear from you fr fr.
and that's the page!! brought to you by BRL-CAD, the PIXMERGE(1) era, with that copyright stretch running 1989-2026 β go forth and merge some pixels bestie πβ¨
π¦ where this page comes from
- nixpkgs unstable: brlcad 7.44.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms