The attached file is a jp2 with rgb and a channels. (I made it in Photoshop and saved it using its "Save a Copy…" feature, which under the hood seems to use kakadu.) Its cdef says that component 0 is color 1 (red), 1 is 2 (blue), 2 is 3 (green), and 3 is alpha associated with the entire image.
kakadu.zip
('jp2h')
('ihdr')
- height = 101
- width = 119
- num_components = 4
- are_components_signed = false
- bits_per_component = 8
- compression_type = 7
- is_colorspace_unknown = 1
- contains_intellectual_property_rights = 0
('colr')
- method = 1
- precedence = 0
- approximation = 1
- enumerated_color_space = 16
('cdef')
- channel_index = 0
- channel_type = 0 (color)
- channel_association = 1
- channel_index = 1
- channel_type = 0 (color)
- channel_association = 2
- channel_index = 2
- channel_type = 0 (color)
- channel_association = 3
- channel_index = 3
- channel_type = 1 (opacity)
- channel_association = 0
If I re-encode this image using jasper, e.g. with build/src/app/jasper --input Tests/LibGfx/test-inputs/jpeg2000/kakadu-lossless-rgba-u8-prog1-layers1-res6-mct.jp2 --output jasper-tile3x2-res5.jp2 -O tilewidth=39 -O tileheight=53 -O numrlvls=5, it doesn't write a cdef box.
I believe this is incorrect.
T.800, I.5.3.6 Channel Definition box: "If the JP2 Header box does not contain a Component Mapping box, then a reader shall map component i to channel i, for all components in the codestream."
T.800 Table 1.18 maps 1 to R, 2 to G, 3 to B, and 4 to nothing. (The spec text probably means "map component i to channel i + 1".) That is, per spec, the last component, alpha, should be ignored if there's no cdef box.
And indeed, Preview.app at least displays jasper's output as if it didn't contain an alpha channel.
jasper should write a cdef box for rgba output.
The attached file is a jp2 with rgb and a channels. (I made it in Photoshop and saved it using its "Save a Copy…" feature, which under the hood seems to use kakadu.) Its cdef says that component 0 is color 1 (red), 1 is 2 (blue), 2 is 3 (green), and 3 is alpha associated with the entire image.
kakadu.zip
If I re-encode this image using jasper, e.g. with
build/src/app/jasper --input Tests/LibGfx/test-inputs/jpeg2000/kakadu-lossless-rgba-u8-prog1-layers1-res6-mct.jp2 --output jasper-tile3x2-res5.jp2 -O tilewidth=39 -O tileheight=53 -O numrlvls=5, it doesn't write a cdef box.I believe this is incorrect.
T.800, I.5.3.6 Channel Definition box: "If the JP2 Header box does not contain a Component Mapping box, then a reader shall map component i to channel i, for all components in the codestream."
T.800 Table 1.18 maps 1 to R, 2 to G, 3 to B, and 4 to nothing. (The spec text probably means "map component i to channel i + 1".) That is, per spec, the last component, alpha, should be ignored if there's no cdef box.
And indeed, Preview.app at least displays jasper's output as if it didn't contain an alpha channel.
jasper should write a cdef box for rgba output.