CrImage::WEBP::TransformEncoder
Inherits Reference / Object
TransformEncoder handles WebP lossless transform operations.
Implements the four VP8L transforms that improve compression:
- Predictor: Predicts pixels from neighbors, encodes differences
- Color: Correlates color channels
- Subtract Green: Removes green from red and blue channels
- Color Indexing (Palette): Reduces to indexed colors
Class methods
Applies color transform to pixels.
Decorrelates color channels by subtracting scaled green from red and blue. Improves compression for natural images.
Returns: Tuple of {tile_bits, block_width, block_height, transform_blocks}
Applies palette transform.
Extracts unique colors as palette, packs pixel indices efficiently (1, 2, 4, or 8 pixels per byte depending on palette size), and applies delta encoding to palette.
Returns: Tuple of {palette, packed_width}
Raises: FormatError if more than 256 unique colors
Applies predictor transform to pixels.
Divides image into tiles, selects best predictor mode for each tile based on entropy, and encodes pixel differences from predictions.
Returns: Tuple of {tile_bits, block_width, block_height, predictor_blocks}
Applies subtract green transform.
Subtracts green channel from red and blue channels. This simple transform exploits correlation between color channels.