Skip to content

Commit 0041db8

Browse files
committed
Merge branch 'release/0.2'
2 parents cb3f8a1 + 515dfda commit 0041db8

File tree

12 files changed

+232
-34
lines changed

12 files changed

+232
-34
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dither
22
obj/
33
imgs/
4-
*.plist
54
*.1

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CFLAGS = -Wall -Isrc/include
2+
LDLIBS = -lpng
23

34
SRCDIR = src
45
OBJDIR = obj
@@ -9,7 +10,7 @@ OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
910
all: dither doc
1011

1112
dither: $(OBJECTS)
12-
$(CC) -o $@ $^
13+
$(CC) $^ $(LDLIBS) -o $@
1314

1415
analyse:
1516
clang $(CFLAGS) --analyze $(SOURCES)

README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Dither - Color Quantization and Dithering
22

33
This is a small program dedicated to reducing the number of colors in an
4-
image. It operates with files in binary PPM format ([Portable PixMap][ppm]),
5-
and features automatic palette generation (using a median-cut algorithm) and
6-
dithering implemented with the Floyd-Steinberg method.
4+
image. It operates with files in PNG or binary PPM format ([Portable
5+
PixMap][ppm]), and features automatic palette generation (using a median-cut
6+
algorithm) and dithering implemented with the Floyd-Steinberg method.
77

88
## Installing
99

10-
#### On macOS with [Homebrew][brew]
10+
#### On macOS with [Homebrew][brw]
1111

1212
$ brew install tessarin/core/dither
1313

1414
#### Manual Installation
1515

16-
Running `make` will compile the program and generate the documentation
17-
(requires Perl). To install, move the executable and manual file to the
18-
appropriate directories.
16+
First, install [`libpng`][lpg]. Running `make` will then compile the program
17+
and generate the documentation (requires Perl). To install, move the
18+
executable and manual files to appropriate directories in your system.
1919

2020
$ make
2121
$ mv dither ~/bin
2222
$ mv dither.1 ~/man/man1
2323

24-
Individual targets can also be specified for only compiling or generating the
25-
manual page:
24+
Individual targets can also be specified to only compile the program or to
25+
generate the manual page:
2626

2727
$ make dither
2828
$ make doc
@@ -47,6 +47,32 @@ processing an image. Other possible palettes include:
4747
Dithering on the final image can be disabled and the program can also be used
4848
just to generate a palette.
4949

50+
## Samples
51+
52+
#### Automatic Palette
53+
54+
$ dither -p auto.32 bird-original.png bird-auto.32.png
55+
56+
![original bird](samples/bird-original.png)
57+
![generated bird](samples/bird-auto.32.png)
58+
59+
#### 1-bit Black & White
60+
61+
$ dither -p bw flower-original.png flower-bw.png
62+
63+
![original flower](samples/flower-original.png)
64+
![generated flower](samples/flower-bw.png)
65+
66+
#### 50% Gray Test
67+
68+
Generates a perfect checkerboard pattern.
69+
70+
$ dither -p bw gray-original.png gray-dithered.png
71+
72+
![original gray](samples/gray-original.png)
73+
![dithered gray](samples/gray-dithered.png)
74+
5075
[ppm]: https://en.wikipedia.org/wiki/Netpbm_format
51-
[brew]: https://brew.sh
76+
[brw]: https://brew.sh
77+
[lpg]: http://www.libpng.org/pub/png/libpng.html
5278
[man]: dither.pod

dither.pod

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ B<dither> [I<-dv>] [I<-p name>[.I<size>]] I<input> I<output>
88

99
=head1 DESCRIPTION
1010

11-
B<dither> processes image files in binary PPM format with the goal of reducing
12-
its number of colors. Functionality includes generating a palette of colors
13-
automatically and writing the output image with the signal optionally dithered
14-
(Floyd-Steinberg method).
11+
B<dither> processes image files in PNG or binary PPM format with the goal of
12+
reducing its number of colors. Functionality includes generating a palette of
13+
colors automatically and writing the output image with the signal optionally
14+
dithered (Floyd-Steinberg method).
1515

1616
Arguments for the input and output file are both required.
1717

1818
The palette used in the operation can be generated from different presets and
1919
sizes, or be completely customized. Details about palette generation are
2020
described below in the corresponding section.
2121

22+
The input file format is deduced by analysing the image header. The output
23+
file format is decided according to its extension. Use a C<.png> extension to
24+
have output written as a PNG file. Any other extension will result in a binary
25+
PPM file.
26+
2227
=head2 Options
2328

2429
Accepted options are:

samples/bird-auto.32.png

95.5 KB
Loading

samples/bird-original.png

130 KB
Loading

samples/flower-bw.png

16.3 KB
Loading

samples/flower-original.png

130 KB
Loading

samples/gray-dithered.png

615 Bytes
Loading

samples/gray-original.png

396 Bytes
Loading

0 commit comments

Comments
 (0)