diff --git a/src/api/heicConvert.ts b/src/api/heicConvert.ts new file mode 100644 index 000000000..0d3586465 --- /dev/null +++ b/src/api/heicConvert.ts @@ -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; +} diff --git a/src/utils/ipcComms.ts b/src/utils/ipcComms.ts index 6235e7e5c..432b28a9b 100644 --- a/src/utils/ipcComms.ts +++ b/src/utils/ipcComms.ts @@ -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); + }); }