summaryrefslogtreecommitdiff
path: root/SPECIFICATION
blob: 2ba71ff8c0188fda78b014f3738ec5e2a7844137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
The imagefile-format is meant to be parsed easily
and used to pipe images losslessly.

# WHY IMAGEFILE?

Most current image-formats have their compression
incorporated in their format itself.
This has some advantages, but reaches its limits
with lossless formats (e.g. PNG).
The basic idea of the imagefile-format is to separate
these to and having a completely transparent image-format.

Pattern resolution is done while compressing, not while
converting the image.
For example, imagefile always stores an alpha-channel,
even if the image doesn't have alpha-variation.
This may sound like a big waste, but as soon as you
compress an image of this kind, the bzip2-algorithm
takes care of the easy pattern, that each 4th character
has the same value.
This leads to almost no overhead while keeping parsing
really simple.

# FORMAT:

Bytes   Description
9	imagefile
4	32 bit BE Integer (width)
4	32 bit BE Integer (height)
[1111]	RGBA-row-aligned-pixel-array

# EXAMPLES:

encoding:
png2if < example.png > example.if
png2if < example.png | bzip2 > example.if.bz2

decoding:
if2png < example.if > example.png
bzcat example.if.bz2 | if2png > example.png

# WHY BZ2?

Using BZ2, you can get smaller filesizes than with PNG,
especially with line-drawings.
For normal pictures, the bz2-compression yields roughly
the same sizes as png does.
Always keep in mind that using PNG involves having to
rely on libpng to decode the image for you, whereas
imagefile is a completely transparent format.