diff --git a/apps/api/src/lib/format-decoders.ts b/apps/api/src/lib/format-decoders.ts index dbd48b8b..da0d5230 100644 --- a/apps/api/src/lib/format-decoders.ts +++ b/apps/api/src/lib/format-decoders.ts @@ -70,11 +70,9 @@ async function decodeIco(buffer: Buffer): Promise { try { await writeFile(inputPath, buffer); // ICO contains multiple sizes; extract the largest by sorting - await execFileAsync( - cmd, - magickArgs(cmd, [`${inputPath}[-1]`, `png:${outputPath}`]), - { timeout: 120_000 }, - ); + await execFileAsync(cmd, magickArgs(cmd, [`${inputPath}[-1]`, `png:${outputPath}`]), { + timeout: 120_000, + }); return await readFile(outputPath); } finally { await rm(inputPath, { force: true }).catch(() => {}); diff --git a/apps/web/src/lib/image-preview.ts b/apps/web/src/lib/image-preview.ts index 3e9474db..d6d29275 100644 --- a/apps/web/src/lib/image-preview.ts +++ b/apps/web/src/lib/image-preview.ts @@ -1,14 +1,21 @@ import { formatHeaders } from "@/lib/api"; const SERVER_PREVIEW_EXTENSIONS = new Set([ - "heic", "heif", "hif", // HEIF - "jxl", // JPEG XL (Chrome dropped support) - "ico", // ICO (Sharp can't decode) - "dng", "cr2", "nef", "arw", "orf", "rw2", // Camera RAW - "tga", // Targa - "psd", // Photoshop - "exr", // OpenEXR - "hdr", // Radiance HDR + "heic", + "heif", + "hif", // HEIF + "jxl", // JPEG XL (Chrome dropped support) + "ico", // ICO (Sharp can't decode) + "dng", + "cr2", + "nef", + "arw", + "orf", + "rw2", // Camera RAW + "tga", // Targa + "psd", // Photoshop + "exr", // OpenEXR + "hdr", // Radiance HDR ]); export function needsServerPreview(file: File): boolean { diff --git a/apps/web/src/pages/tool-page.tsx b/apps/web/src/pages/tool-page.tsx index d02aae7a..37b011ae 100644 --- a/apps/web/src/pages/tool-page.tsx +++ b/apps/web/src/pages/tool-page.tsx @@ -250,7 +250,8 @@ export function ToolPage() { const input = document.createElement("input"); input.type = "file"; input.multiple = true; - input.accept = "image/*,.heic,.heif,.hif,.jxl,.dng,.cr2,.nef,.arw,.orf,.rw2,.tga,.psd,.exr,.hdr"; + input.accept = + "image/*,.heic,.heif,.hif,.jxl,.dng,.cr2,.nef,.arw,.orf,.rw2,.tga,.psd,.exr,.hdr"; input.onchange = (e) => { const newFiles = Array.from((e.target as HTMLInputElement).files || []); if (newFiles.length > 0) addFiles(newFiles); diff --git a/packages/image-engine/src/operations/compress.ts b/packages/image-engine/src/operations/compress.ts index a24fdcef..970c35ec 100644 --- a/packages/image-engine/src/operations/compress.ts +++ b/packages/image-engine/src/operations/compress.ts @@ -22,9 +22,9 @@ export async function compress(image: Sharp, options: CompressOptions): Promise< const metadata = await image.metadata(); const detected = metadata.format ?? "jpeg"; - const outputFormat = ( - FORMAT_MAP[format ?? ""] ?? FORMAT_MAP[detected] ?? detected - ) as keyof import("sharp").FormatEnum; + const outputFormat = (FORMAT_MAP[format ?? ""] ?? + FORMAT_MAP[detected] ?? + detected) as keyof import("sharp").FormatEnum; if (targetSizeBytes !== undefined) { if (targetSizeBytes <= 0) { diff --git a/packages/image-engine/src/types.ts b/packages/image-engine/src/types.ts index c5543c7f..0515e359 100644 --- a/packages/image-engine/src/types.ts +++ b/packages/image-engine/src/types.ts @@ -17,7 +17,16 @@ export interface OperationResult { info: ImageInfo; } -export type OutputFormat = "jpg" | "png" | "webp" | "avif" | "tiff" | "gif" | "heic" | "heif" | "jxl"; +export type OutputFormat = + | "jpg" + | "png" + | "webp" + | "avif" + | "tiff" + | "gif" + | "heic" + | "heif" + | "jxl"; export interface ResizeOptions { width?: number;