Skip to content

Commit 5b9e267

Browse files
committed
fix: use -colors 2 instead of -monochrome for Floyd-Steinberg 1-bit dithering
-monochrome and -type Bilevel force a 50% threshold algorithm that discards the Floyd-Steinberg error diffusion matrix, resulting in hard threshold cut-off instead of the expected dither pattern. Using -colors 2 preserves the error diffusion while still reducing to a 2-color palette. Fixes #48
1 parent 3680950 commit 5b9e267

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

trmnl-ha/ha-trmnl/lib/dithering/floyd-steinberg-strategy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export class FloydSteinbergStrategy implements DitheringStrategy {
4747
if (mode === 'grayscale') {
4848
if (colors === 2) {
4949
// Binary (black & white) with error diffusion
50-
return image.out('-dither', 'FloydSteinberg').out('-monochrome')
50+
// Using -colors 2 instead of -monochrome or -type Bilevel, as those
51+
// force a 50% threshold that discards the Floyd-Steinberg error diffusion.
52+
// Bit-depth reduction is handled later by configureOutputFormat.
53+
return image.out('-dither', 'FloydSteinberg').out('-colors', '2')
5154
} else if (colors !== undefined && colors > 2) {
5255
// Multi-level grayscale with error diffusion
5356
return image

0 commit comments

Comments
 (0)