update electron heicConvertor

This commit is contained in:
Abhinav 2022-10-15 00:41:20 +05:30
parent 3db124bc41
commit 2096d09e0d

View file

@ -8,10 +8,13 @@ class ElectronHEICConverter {
this.electronAPIs = globalThis['ElectronAPIs'];
this.allElectronAPIExists = !!this.electronAPIs?.convertHEIC;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async convert(fileBlob: Blob, format = 'JPEG'): Promise<Blob> {
apiExists() {
return this.allElectronAPIExists;
}
async convert(fileBlob: Blob): Promise<Blob> {
try {
console.log(this.electronAPIs);
if (this.allElectronAPIExists) {
const inputFileData = new Uint8Array(
await fileBlob.arrayBuffer()
@ -19,11 +22,11 @@ class ElectronHEICConverter {
const convertedFileData = await this.electronAPIs.convertHEIC(
inputFileData
);
console.log('convertedFileData', convertedFileData.length);
return new Blob([convertedFileData]);
}
} catch (e) {
logError(e, 'failed to convert heic natively');
throw e;
}
}
}