|
@@ -3,7 +3,6 @@ import fs from "node:fs/promises";
|
|
|
import path from "path";
|
|
|
import { CustomErrors, ElectronFile } from "../../types/ipc";
|
|
|
import log from "../log";
|
|
|
-import { isPlatform } from "../platform";
|
|
|
import { writeStream } from "../stream";
|
|
|
import { generateTempFilePath } from "../temp";
|
|
|
import { execAsync, isDev } from "../util";
|
|
@@ -77,9 +76,8 @@ export async function convertToJPEG(
|
|
|
fileData: Uint8Array,
|
|
|
filename: string,
|
|
|
): Promise<Uint8Array> {
|
|
|
- if (isPlatform("windows")) {
|
|
|
+ if (process.platform == "win32")
|
|
|
throw Error(CustomErrors.WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED);
|
|
|
- }
|
|
|
const convertedFileData = await convertToJPEG_(fileData, filename);
|
|
|
return convertedFileData;
|
|
|
}
|
|
@@ -126,7 +124,7 @@ function constructConvertCommand(
|
|
|
tempOutputFilePath: string,
|
|
|
) {
|
|
|
let convertCmd: string[];
|
|
|
- if (isPlatform("mac")) {
|
|
|
+ if (process.platform == "darwin") {
|
|
|
convertCmd = SIPS_HEIC_CONVERT_COMMAND_TEMPLATE.map((cmdPart) => {
|
|
|
if (cmdPart === INPUT_PATH_PLACEHOLDER) {
|
|
|
return tempInputFilePath;
|
|
@@ -136,7 +134,7 @@ function constructConvertCommand(
|
|
|
}
|
|
|
return cmdPart;
|
|
|
});
|
|
|
- } else if (isPlatform("linux")) {
|
|
|
+ } else if (process.platform == "linux") {
|
|
|
convertCmd = IMAGEMAGICK_HEIC_CONVERT_COMMAND_TEMPLATE.map(
|
|
|
(cmdPart) => {
|
|
|
if (cmdPart === IMAGE_MAGICK_PLACEHOLDER) {
|
|
@@ -165,11 +163,10 @@ export async function generateImageThumbnail(
|
|
|
let inputFilePath = null;
|
|
|
let createdTempInputFile = null;
|
|
|
try {
|
|
|
- if (isPlatform("windows")) {
|
|
|
+ if (process.platform == "win32")
|
|
|
throw Error(
|
|
|
CustomErrors.WINDOWS_NATIVE_IMAGE_PROCESSING_NOT_SUPPORTED,
|
|
|
);
|
|
|
- }
|
|
|
if (!existsSync(inputFile.path)) {
|
|
|
const tempFilePath = await generateTempFilePath(inputFile.name);
|
|
|
await writeStream(tempFilePath, await inputFile.stream());
|
|
@@ -240,7 +237,7 @@ function constructThumbnailGenerationCommand(
|
|
|
quality: number,
|
|
|
) {
|
|
|
let thumbnailGenerationCmd: string[];
|
|
|
- if (isPlatform("mac")) {
|
|
|
+ if (process.platform == "darwin") {
|
|
|
thumbnailGenerationCmd = SIPS_THUMBNAIL_GENERATE_COMMAND_TEMPLATE.map(
|
|
|
(cmdPart) => {
|
|
|
if (cmdPart === INPUT_PATH_PLACEHOLDER) {
|
|
@@ -258,7 +255,7 @@ function constructThumbnailGenerationCommand(
|
|
|
return cmdPart;
|
|
|
},
|
|
|
);
|
|
|
- } else if (isPlatform("linux")) {
|
|
|
+ } else if (process.platform == "linux") {
|
|
|
thumbnailGenerationCmd =
|
|
|
IMAGE_MAGICK_THUMBNAIL_GENERATE_COMMAND_TEMPLATE.map((cmdPart) => {
|
|
|
if (cmdPart === IMAGE_MAGICK_PLACEHOLDER) {
|