Best practices for Quantization
masterWhen using UPNG.quantize() or preparing data for processing, follow these guidelines:
- Multiple Images: To generate one common palette for multiple images (like animation frames), concatenate them into a single
dataarray. - Fewer than 4 components: If working with less than four components (e.g., grayscale), set the remaining components to a constant value (e.g., zero).
- Transparency: When working with transparency, premultiply color components by the transparency value. This prevents transparent pixels from being incorrectly mapped to colors like white (e.g.,
rgba(1,1,1,0)should be handled so it is closer torgba(0,0,0,0)thanrgba(1,1,1,1)).