29 | export const PNG_HEADER = new Uint8Array([
30 | 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
31 | ]);
32 |
33 | /**
34 | * An enum for Intent when specifying sRGB chunk.
35 | *
36 | * @enum {Intent}
37 | * @property {number} Perceptual (0x00)
38 | * @property {number} Relative relative colorimetric (0x01)
39 | * @property {number} Saturation (0x02)
40 | * @property {number} Absolute absolute colorimetric (0x03)
41 | **/
42 | export const Intent = Object.freeze({
43 | Perceptual: 0,
44 | Relative: 1, // Relative colorimetric
45 | Saturation: 2,
46 | Absolute: 3, // Aboslute colorimetric
47 | });
48 |
49 | /**
50 | * An enum for standard PNG scanline filter methods.
51 | *
52 | * @enum {FilterMethod}
53 | * @property {number} None No filter (0x00)
54 | * @property {number} Sub Compute from left (0x01)
55 | * @property {number} Up Compute from above scanline (0x02)
56 | * @property {number} Average Compute from average of up and left (0x03)
57 | * @property {number} Paeth Compute the PNG 'paeth' predictor from up & left (0x04)
58 | **/
59 | export const FilterMethod = Object.freeze({
60 | None: 0x00,
61 | Sub: 0x01,
62 | Up: 0x02,
63 | Average: 0x03,
64 | Paeth: 0x04,
65 | });
66 |
67 | /**
68 | * An enum for standard PNG color types, such as RGB or RGBA.
69 | *
70 | * @enum {ColorType}
71 | * @property {number} GRAYSCALE (1)
72 | * @property {number} RGB (2)
73 | * @property {number} INDEXED (3)
74 | * @property {number} GRAYSCALE_ALPHA (4)
75 | * @property {number} RGBA (6)
76 | **/
77 | export const ColorType = Object.freeze({
78 | GRAYSCALE: 1,
79 | RGB: 2,
80 | INDEXED: 3,
81 | GRAYSCALE_ALPHA: 4,
82 | RGBA: 6,
83 | });
84 |
85 | /**
86 | * An enum for standard PNG chunk type codes (4-byte Uint32 decimal), including critical and ancillary chunks.
87 | *
88 | * @enum {ChunkType}
89 | * @property {number} IHDR
90 | * @property {number} PLTE
91 | * @property {number} IDAT
92 | * @property {number} IEND
93 | * @property {number} (...) - see source for full list
94 | * */
95 | export const ChunkType = Object.freeze({
96 | // Critical chunks
97 | IHDR: 0x49484452,
98 | PLTE: 0x504c5445,
99 | IDAT: 0x49444154,
100 | IEND: 0x49454e44,
101 | // Ancillary Chunks
102 | cHRM: 0x6348524d,
103 | gAMA: 0x67414d41,
104 | iCCP: 0x69434350,
105 | sBIT: 0x73424954,
106 | sRGB: 0x73524742,
107 | bKGD: 0x624b4744,
108 | hIST: 0x68495354,
109 | tRNS: 0x74524e53,
110 | pHYs: 0x70485973,
111 | sPLT: 0x73504c54,
112 | tIME: 0x74494d45,
113 | iTXt: 0x69545874,
114 | tEXt: 0x74455874,
115 | zTXt: 0x7a545874,
116 | });
117 |
118 |
119 |