setup data pipeline to convert heic natively

This commit is contained in:
Abhinav 2022-10-14 22:48:12 +05:30
parent c5c20ae0c0
commit c63060780c
2 changed files with 19 additions and 0 deletions

14
src/api/heicConvert.ts Normal file
View file

@ -0,0 +1,14 @@
import { ipcRenderer } from 'electron/renderer';
import { isPlatformMac } from '../utils/main';
export async function convertHEIC(fileData: Uint8Array, outputType: string) {
if (!isPlatformMac()) {
throw Error('native heic conversion only supported on mac');
}
const convertedFileData = await ipcRenderer.invoke(
'convert-heic',
fileData,
outputType
);
return convertedFileData;
}

View file

@ -13,6 +13,7 @@ import { logErrorSentry } from '../services/sentry';
import chokidar from 'chokidar';
import path from 'path';
import { getDirFilePaths } from '../services/fs';
import { convertHEIC } from '../services/heicConversion';
export default function setupIpcComs(
tray: Tray,
@ -96,4 +97,8 @@ export default function setupIpcComs(
ipcMain.handle('get-path', (_, message) => {
return app.getPath(message);
});
ipcMain.handle('convert-heic', (_, fileData, outputType) => {
return convertHEIC(fileData, outputType);
});
}