Use the implementation instead of the accidental infinite loop

This commit is contained in:
Manav Rathi 2024-04-05 10:51:04 +05:30
parent e7e8ded1ed
commit e0cfa36f08
No known key found for this signature in database
2 changed files with 17 additions and 16 deletions

View file

@ -1,15 +0,0 @@
import HeicConvert from "heic-convert";
import { getUint8ArrayView } from "services/readerService";
/**
* Convert a HEIC file to a JPEG file.
*
* Both the input and output are blobs.
*/
export const convertHEICToJPEG = async (heicBlob: Blob): Promise<Blob> => {
const filedata = await getUint8ArrayView(heicBlob);
const result = await HeicConvert({ buffer: filedata, format: "JPEG" });
const convertedFileData = new Uint8Array(result);
const convertedFileBlob = new Blob([convertedFileData]);
return convertedFileBlob;
};

View file

@ -1,9 +1,25 @@
import * as Comlink from "comlink";
import HeicConvert from "heic-convert";
import { getUint8ArrayView } from "services/readerService";
export class DedicatedConvertWorker {
async convertHEICToJPEG(fileBlob: Blob) {
return this.convertHEICToJPEG(fileBlob);
return convertHEICToJPEG(fileBlob);
}
}
Comlink.expose(DedicatedConvertWorker, self);
/**
* Convert a HEIC file to a JPEG file.
*
* Both the input and output are blobs.
*/
export const convertHEICToJPEG = async (heicBlob: Blob): Promise<Blob> => {
console.log("test")
const filedata = await getUint8ArrayView(heicBlob);
const result = await HeicConvert({ buffer: filedata, format: "JPEG" });
const convertedFileData = new Uint8Array(result);
const convertedFileBlob = new Blob([convertedFileData]);
return convertedFileBlob;
};