@@ -2,6 +2,7 @@ const test = require('tape')
22const PromiseFileReader = require ( 'promise-file-reader' )
33
44const readImageArrayBuffer = require ( 'itkreadImageArrayBuffer.js' )
5+ const readImageBlob = require ( 'itkreadImageBlob.js' )
56const readImageFile = require ( 'itkreadImageFile.js' )
67
78const IntTypes = require ( 'itkIntTypes.js' )
@@ -44,6 +45,28 @@ test('readImageArrayBuffer reads an ArrayBuffer', t => {
4445 } )
4546} )
4647
48+ test ( 'readImageBlob reads an Blob' , t => {
49+ return readImageBlob ( cthead1SmallBlob , 'cthead1Small.png' ) . then ( function ( image ) {
50+ t . is ( image . imageType . dimension , 2 , 'dimension' )
51+ t . is ( image . imageType . componentType , IntTypes . UInt8 , 'componentType' )
52+ t . is ( image . imageType . pixelType , PixelTypes . Scalar , 'pixelType' )
53+ t . is ( image . imageType . components , 1 , 'components' )
54+ t . is ( image . origin [ 0 ] , 0.0 , 'origin[0]' )
55+ t . is ( image . origin [ 1 ] , 0.0 , 'origin[1]' )
56+ t . is ( image . spacing [ 0 ] , 1.0 , 'spacing[0]' )
57+ t . is ( image . spacing [ 1 ] , 1.0 , 'spacing[1]' )
58+ t . is ( getMatrixElement ( image . direction , 0 , 0 ) , 1.0 , 'direction (0, 0)' )
59+ t . is ( getMatrixElement ( image . direction , 0 , 1 ) , 0.0 , 'direction (0, 1)' )
60+ t . is ( getMatrixElement ( image . direction , 1 , 0 ) , 0.0 , 'direction (1, 0)' )
61+ t . is ( getMatrixElement ( image . direction , 1 , 1 ) , 1.0 , 'direction (1, 1)' )
62+ t . is ( image . size [ 0 ] , 32 , 'size[0]' )
63+ t . is ( image . size [ 1 ] , 32 , 'size[1]' )
64+ t . is ( image . buffer . length , 1024 , 'buffer.length' )
65+ t . is ( image . buffer [ 512 ] , 12 , 'buffer[512]' )
66+ t . end ( )
67+ } )
68+ } )
69+
4770test ( 'readImageFile reads a File' , t => {
4871 return readImageFile ( cthead1SmallFile ) . then ( function ( image ) {
4972 t . is ( image . imageType . dimension , 2 , 'dimension' )
0 commit comments