Skip to content

fix(image-io): resolve IWI CBOR round-trip corruption for uint8 images#1485

Open
thewtex wants to merge 9 commits intomainfrom
274d-investigate-crea
Open

fix(image-io): resolve IWI CBOR round-trip corruption for uint8 images#1485
thewtex wants to merge 9 commits intomainfrom
274d-investigate-crea

Conversation

@thewtex
Copy link
Member

@thewtex thewtex commented Feb 10, 2026

Make ReadCBOR key-order independent by deferring pixel data copy until
after all metadata keys are processed. Previously, if the 'data' key
appeared before 'imageType' or 'size' in the CBOR map, GetImageSizeInBytes()
would use default values (float32), causing a 4x buffer overread for uint8
images and producing corrupted output.

Also skip unknown CBOR map keys instead of throwing, improving
interoperability with third-party CBOR writers like NiiVue's cbor-x.

Add uint64 to the glaze enumerate list in itkComponentTypesJSON.h so
JSON deserialization of uint64 componentType no longer silently fails.

Replace empty Python test stubs with comprehensive tests covering
IWI CBOR read, write, zstd read/write, and cross-format round-trips
(PNG/MHA/NRRD through IWI CBOR) for multiple component types.

Make ReadCBOR key-order independent by deferring pixel data copy until
after all metadata keys are processed. Previously, if the 'data' key
appeared before 'imageType' or 'size' in the CBOR map, GetImageSizeInBytes()
would use default values (float32), causing a 4x buffer overread for uint8
images and producing corrupted output.

Also skip unknown CBOR map keys instead of throwing, improving
interoperability with third-party CBOR writers like NiiVue's cbor-x.

Add uint64 to the glaze enumerate list in itkComponentTypesJSON.h so
JSON deserialization of uint64 componentType no longer silently fails.

Replace empty Python test stubs with comprehensive tests covering
IWI CBOR read, write, zstd read/write, and cross-format round-trips
(PNG/MHA/NRRD through IWI CBOR) for multiple component types.
quay.io is having multi-arch manifest issues.
…forward compatibility

Replace itkExceptionMacro throws with silent skips for unrecognized
CBOR map keys in ReadCBOR across all three IO classes:

- itkWasmImageIO: imageType inner sub-map (top-level was already fixed)
- itkWasmMeshIO: meshType inner sub-map + explicit top-level else clause
- itkWasmTransformIO: transformType inner sub-map + explicit top-level else clause

This improves interoperability with third-party CBOR writers (e.g. NiiVue)
that may include additional or extended fields in the type sub-maps.

Also replace empty test stubs in transform-io with real round-trip tests
for wasm-zstd and MNC (.xfm) formats, using programmatically created
affine transforms to avoid dependency on IPFS test data downloads.
@thewtex thewtex force-pushed the 274d-investigate-crea branch from 2a34266 to a595527 Compare February 17, 2026 16:24
@thewtex thewtex force-pushed the 274d-investigate-crea branch from c844031 to 5620cae Compare February 24, 2026 15:52
@thewtex thewtex force-pushed the 274d-investigate-crea branch from 5620cae to dfacf23 Compare February 24, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant