From 2f1b5a73ff4eec2ce7573722ea9df15f65f2261c Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Thu, 4 Apr 2024 08:09:13 -0400 Subject: [PATCH] fix(typescript): add imageType property to Image --- .../typescript/src/interface-type-json-node.ts | 17 +++++++++++++++++ .../itk-wasm/src/interface-types/image.ts | 7 +++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 packages/compress-stringify/typescript/src/interface-type-json-node.ts diff --git a/packages/compress-stringify/typescript/src/interface-type-json-node.ts b/packages/compress-stringify/typescript/src/interface-type-json-node.ts new file mode 100644 index 000000000..93ff9348c --- /dev/null +++ b/packages/compress-stringify/typescript/src/interface-type-json-node.ts @@ -0,0 +1,17 @@ +import { + Image, + Mesh, + PolyData, +} from 'itk-wasm' + +import compressStringify from './compress-stringify.js' +import parseStringDecompress from './parse-string-decompress.js' +import { dir } from 'console' + +export function imageToJson(image: Image): string { + const level = 5 + + const directionBytes = new Uint8Array(image.direction.buffer) + image.direction = await compressStringify(directionBytes, { compressionLevel: level, stringify: True }) + +} \ No newline at end of file diff --git a/packages/core/typescript/itk-wasm/src/interface-types/image.ts b/packages/core/typescript/itk-wasm/src/interface-types/image.ts index 8e6fc854d..a39d46d0e 100644 --- a/packages/core/typescript/itk-wasm/src/interface-types/image.ts +++ b/packages/core/typescript/itk-wasm/src/interface-types/image.ts @@ -4,6 +4,8 @@ import setMatrixElement from '../set-matrix-element.js' import Metadata from './metadata.js' class Image { + imageType: ImageType + name: string = 'image' origin: number[] @@ -18,8 +20,9 @@ class Image { data: null | TypedArray - constructor (public readonly imageType = new ImageType()) { - const dimension = imageType.dimension + constructor (public readonly it = new ImageType()) { + this.imageType = it + const dimension = it.dimension this.origin = new Array(dimension) this.origin.fill(0.0)