Inline
This commit is contained in:
parent
7d122f825c
commit
6ce956c5bb
|
@ -220,8 +220,7 @@ class FaceService {
|
||||||
face.detection,
|
face.detection,
|
||||||
);
|
);
|
||||||
|
|
||||||
const blobOptions = DEFAULT_ML_SYNC_CONFIG.faceCrop.blobOptions;
|
const blob = await imageBitmapToBlob(faceCrop.image);
|
||||||
const blob = await imageBitmapToBlob(faceCrop.image, blobOptions);
|
|
||||||
|
|
||||||
const cache = await openCache("face-crops");
|
const cache = await openCache("face-crops");
|
||||||
await cache.put(face.id, blob);
|
await cache.put(face.id, blob);
|
||||||
|
|
|
@ -450,17 +450,17 @@ export interface BlobOptions {
|
||||||
quality?: number;
|
quality?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function imageBitmapToBlob(
|
export async function imageBitmapToBlob(imageBitmap: ImageBitmap) {
|
||||||
imageBitmap: ImageBitmap,
|
|
||||||
options?: BlobOptions,
|
|
||||||
) {
|
|
||||||
const offscreen = new OffscreenCanvas(
|
const offscreen = new OffscreenCanvas(
|
||||||
imageBitmap.width,
|
imageBitmap.width,
|
||||||
imageBitmap.height,
|
imageBitmap.height,
|
||||||
);
|
);
|
||||||
offscreen.getContext("2d").drawImage(imageBitmap, 0, 0);
|
offscreen.getContext("2d").drawImage(imageBitmap, 0, 0);
|
||||||
|
|
||||||
return offscreen.convertToBlob(options);
|
return offscreen.convertToBlob({
|
||||||
|
type: "image/jpeg",
|
||||||
|
quality: 0.8,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function imageBitmapFromBlob(blob: Blob) {
|
export async function imageBitmapFromBlob(blob: Blob) {
|
||||||
|
|
Loading…
Reference in a new issue