( image: ImageSource, _: Config )
| 104 | } |
| 105 | |
| 106 | async function imageSourceToImageData( |
| 107 | image: ImageSource, |
| 108 | _: Config |
| 109 | ): Promise<NdArray<Uint8Array>> { |
| 110 | if (typeof image === 'string') { |
| 111 | image = ensureAbsoluteURI(image, `file://${process.cwd()}/`); |
| 112 | } |
| 113 | if (image instanceof URL) { |
| 114 | image = await (await loadFromURI(image)).blob(); |
| 115 | } |
| 116 | if (image instanceof ArrayBuffer || ArrayBuffer.isView(image)) { |
| 117 | image = new Blob([image]); |
| 118 | } |
| 119 | if (image instanceof Blob) { |
| 120 | image = await codecs.imageDecode(image); |
| 121 | } |
| 122 | |
| 123 | return image as NdArray<Uint8Array>; |
| 124 | } |
| 125 | |
| 126 | function convertFloat32ToUint8( |
| 127 | float32Array: NdArray<Float32Array> |
nothing calls this directly
no test coverage detected