MCPcopy
hub / github.com/tensorflow/tfjs / encodeImage

Function encodeImage

tfjs-node/src/image.ts:253–265  ·  view source on GitHub ↗
(
    image: Tensor3D, backendEncodeImage: (imageData: Uint8Array) => Tensor)

Source from the content-addressed store, hash-verified

251}
252
253async 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.

Callers 2

encodeJpegFunction · 0.85
encodePngFunction · 0.85

Calls 3

backendEncodeImageFunction · 0.85
dataMethod · 0.65
disposeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…