(
image: Tensor3D, backendEncodeImage: (imageData: Uint8Array) => Tensor)
| 251 | } |
| 252 | |
| 253 | async function encodeImage( |
| 254 | image: Tensor3D, backendEncodeImage: (imageData: Uint8Array) => Tensor): |
| 255 | Promise<Uint8Array> { |
| 256 | const encodedDataTensor = |
| 257 | backendEncodeImage(new Uint8Array(await image.data())); |
| 258 | |
| 259 | const encodedPngData = |
| 260 | ( |
| 261 | // tslint:disable-next-line:no-any |
| 262 | await encodedDataTensor.data())[0] as any as Uint8Array; |
| 263 | encodedDataTensor.dispose(); |
| 264 | return encodedPngData; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Helper function to get image type based on starting bytes of the image file. |
no test coverage detected
searching dependent graphs…