getImagickStaticPath

This commit is contained in:
Abhinav 2022-12-03 14:17:49 +05:30
parent 750bd46315
commit 7a59818e58
2 changed files with 10 additions and 3 deletions

View file

@ -8,7 +8,7 @@ import { getSkipAppVersion, setSkipAppVersion } from './userPreference';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
import { logErrorSentry } from './sentry'; import { logErrorSentry } from './sentry';
import ElectronLog from 'electron-log'; import ElectronLog from 'electron-log';
import { isPlatform } from 'utils/main'; import { isPlatform } from '../utils/main';
const FIVE_MIN_IN_MICROSECOND = 5 * 60 * 1000; const FIVE_MIN_IN_MICROSECOND = 5 * 60 * 1000;

View file

@ -6,10 +6,17 @@ import { readFile, writeFile } from 'promise-fs';
import { generateTempFilePath } from '../utils/temp'; import { generateTempFilePath } from '../utils/temp';
import { logErrorSentry } from './sentry'; import { logErrorSentry } from './sentry';
import { isPlatform } from '../utils/main'; import { isPlatform } from '../utils/main';
import pathToImageMagick from '../pkg/image-magick-static'; import { isDev } from '../utils/common';
import path from 'path';
const asyncExec = util.promisify(exec); const asyncExec = util.promisify(exec);
function getImageMagickStaticPath() {
return isDev
? 'build/image-magick'
: path.join(process.resourcesPath, 'image-magick');
}
export async function convertHEIC( export async function convertHEIC(
heicFileData: Uint8Array heicFileData: Uint8Array
): Promise<Uint8Array> { ): Promise<Uint8Array> {
@ -54,7 +61,7 @@ async function runConvertCommand(
); );
} else if (isPlatform('linux')) { } else if (isPlatform('linux')) {
await asyncExec( await asyncExec(
`${pathToImageMagick} ${tempInputFilePath} -quality 100% ${tempOutputFilePath}` `${getImageMagickStaticPath()} ${tempInputFilePath} -quality 100% ${tempOutputFilePath}`
); );
} else { } else {
Error(`${process.platform} native heic convert not supported yet`); Error(`${process.platform} native heic convert not supported yet`);