Skip to content

Commit

Permalink
test(image-io): port node bio-rad-test
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Oct 5, 2023
1 parent eec412b commit a8a8015
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/image-io/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itk-wasm/image-io",
"version": "1.0.0",
"version": "0.1.0",
"description": "Input and output for scientific and medical image file formats.",
"type": "module",
"module": "./dist/bundles/image-io.js",
Expand Down
27 changes: 7 additions & 20 deletions packages/image-io/typescript/test/node/bio-rad-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ import test from 'ava'
import path from 'path'
import fs from 'fs'

function mkdirP(dir) {
try {
fs.mkdirSync(dir, { recursive: true })
} catch (err) {
if (err.code !== 'EEXIST') throw err
}
}

import { bioRadReadImageNode, bioRadWriteImageNode } from '../../dist/bundles/image-io-node.js'
import { IntTypes, PixelTypes, getMatrixElement } from 'itk-wasm'

const testInputFilePath = path.resolve('..', 'test', 'data', 'input', 'biorad.pic')
const testOutputPath = path.resolve('..', 'test', 'output', 'typescript')
fs.mkdirSync(testOutputPath, { recursive: true })
const testOutputFilePath = path.join(testOutputPath, 'biorad.pic')

const verifyImage = (t, image) => {
Expand All @@ -37,6 +30,7 @@ const verifyImage = (t, image) => {
}

test('Test reading a BioRad file', async t => {
console.log(testInputFilePath)
const { couldRead, image } = await bioRadReadImageNode(testInputFilePath)
t.true(couldRead)
verifyImage(t, image)
Expand All @@ -46,17 +40,10 @@ test('Test writing a BioRad file', async t => {
const { couldRead, image } = await bioRadReadImageNode(testInputFilePath)
t.true(couldRead)
const useCompression = false
const { couldWrite, serializedImage } = await bioRadWriteImageNode(image, { useCompression })
console.log(couldWrite, serializedImage)
const { couldWrite } = await bioRadWriteImageNode(image, testOutputFilePath, { useCompression })
t.true(couldWrite)

// verifyImage(t, image)
// return readImageLocalFile(testInputFilePath).then(function (image) {
// const useCompression = false
// return writeImageLocalFile(image, testOutputFilePath, useCompression)
// })
// .then(function () {
// return readImageLocalFile(testOutputFilePath).then(function (image) {
// verifyImage(t, image)
// })
// })
const { couldRead: couldReadBack, image: imageBack } = await bioRadReadImageNode(testOutputFilePath)
t.true(couldReadBack)
verifyImage(t, imageBack)
})

0 comments on commit a8a8015

Please sign in to comment.