Skip to content

[Bug] writeImageNode crashes with Uint32Array, but not Uint8Array or Uint16Array #1544

Description

@Modjular

Crashes with both writeImage from the cdn or writeImageNode in nodejs.

Let me know if this is expected behavior or not. The documentation seems to indicate uint32 should be supported.

Repro:

import { writeImageNode } from '@itk-wasm/image-io'

const dtypes = [
    {componentType: 'uint8', data: new Uint8Array(100*100), name: 'uint8_test'},
    {componentType: 'uint16', data: new Uint16Array(100*100), name: 'uint16_test'},
    {componentType: 'uint32', data: new Uint32Array(100*100), name: 'uint32_test'},
]

dtypes.forEach(async (d) => {
    console.log("Writing", d.name)

    const res = await writeImageNode(
        {
            imageType: {
                dimension: 2,
                pixelType: 'Scalar',
                componentType: d.componentType,
                components: 1
            },
            name: d.name,
            direction: new Float64Array([1.0, 0.0, 0.0, 1.0]),
            size: [100, 100],
            data: d.data, // <- !!! Will crash if Uint32Array
        },d.name + '.tif')

    console.log(d.name, res)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions