Optional
ancillaryAdditional metadata to encode as chunks in the png.
Optional
bitThe bit depth to encode with. When unspecified, the library will scan the image and determine the best value based on the content, it's best to pass this in if know to avoid the scan iterating over every pixel in the image.
Optional
colorWhat color type to encode with. Remarks:
tRNS
chunk will be used, depending on which consumes less bytes.Optional
filterAn optional filter pattern used for testing. This is internal only as it's not useful outside of testing to ensure each permutation is correct, unless the image is analyzed outside of the library but that's out of scope for this library.
Optional
strictEnabled strict encoding which will throw when warnings are encountered.
An optional set of options to encode an image with. The options override the specified property when encoding, except for the case where it's not possible to encode the image with that option at which point it will be overridden (unless IEncodePngOptions.strictMode is used).
Example
Example
Throws
An EncodeError when an error is encountered or a EncodeWarning when a warning is encountered in strict mode. In Typescript,
instanceof
can be used to narrow the type safely.