Closed targos closed 2 months ago
It would be helpful to have a table in the documentation that shows how each color model is encoded
Have on column with the color model / bit depth of the original image and another with the color model / bit depth of decode(encode(image))
Here is what I came up with.
DECODE | 8bits | 16bits | 32bits | Gray | RGB | Alpha |
---|---|---|---|---|---|---|
TIFF | Yes | Yes | Yes | Yes | Yes | Yes |
PNG | Yes | Yes | No | Yes | Yes | Yes |
JPEG | Yes | No | No | Yes | Yes | No |
BMP is not there because it is not supported for decoding.TIFF and PNG can be decoded as anything. JPEG converts gray and rgb 8-bit images, but once decoded it sets colorModel as RGBA.
ENCODE | 1bit | 8bit | 16bit | Gray | RGB | Alpha |
---|---|---|---|---|---|---|
PNG | No | Yes | Yes | Yes | Yes | Yes |
JPEG | No | Yes | No | No | Yes | No |
BMP | Yes | No | No | No | No | No |
We don't support TIFF encoding. JPEG converts any image into 8 bit RGB. Again, important to note that it works only if the data's colorModel is set as RGBA. PNG has the same encoding capabilities as decoding. BMP can encode only binary images.
I think each
encode***
function should handle its own automatic conversion based on what the encoder supports, or throw if the conversion cannot be done in a meaningful way.