Indexed color PNG image generator.
pzntg.create(options) → String (base64) | Uint8Array
- options (object, required).
Supported options:
- pixels (matrix, required).
- palette (matrix, required).
- scale (positive integer, optional, default = 1).
- asBase64 (boolean, optional, default = true).
- zlib_level (integer from 0 to 9, optional, default = Z_DEFAULT_COMPRESSION).
- zlib_strategy (integer from 0 to 4, optional, default = Z_RLE).
- zlib_memlevel (integer from 1 to 9, optional, default = 8).
- callback (function, optional).
If callback is not defined, value is returned.
Read this for more information about zlib options.
pzntg.create({
pixels: [
[0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0],
[0,0,0,0,0,1,1,1,1,2,2,2,2,1,1,1,2,2,2,2,1,1,1,1,0,0,0,0,0],
[0,0,0,0,0,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,0,0,0,0,0],
[0,0,0,0,0,1,1,2,2,2,4,2,2,2,2,2,2,2,4,2,2,2,1,1,0,0,0,0,0],
[0,5,5,5,5,1,1,2,2,4,3,4,2,2,2,2,2,4,3,4,2,2,1,1,5,5,5,5,0],
[0,0,0,0,0,1,1,2,2,4,3,4,2,2,2,2,2,4,3,4,2,2,1,1,0,0,0,0,0],
[0,5,5,5,5,1,1,2,2,2,4,2,2,2,3,2,2,2,4,2,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