mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Merge branch 'feat/format-support-expansion'
# Conflicts: # README.md # apps/web/src/components/layout/app-layout.tsx
This commit is contained in:
@@ -10,10 +10,11 @@ const FORMAT_MAP: Record<string, string> = {
|
||||
heif: "avif",
|
||||
tiff: "tiff",
|
||||
gif: "gif",
|
||||
jxl: "jxl",
|
||||
};
|
||||
|
||||
/** Formats that Sharp cannot encode — fall back to PNG for output. */
|
||||
const NO_ENCODER = new Set(["svg", "bmp", "raw", "tga", "psd", "exr", "hdr", "ico"]);
|
||||
const NO_ENCODER = new Set(["svg", "raw", "tga", "psd", "exr", "hdr"]);
|
||||
|
||||
function formatOpts(format: string, quality: number): Record<string, unknown> {
|
||||
const opts: Record<string, unknown> = { quality };
|
||||
|
||||
@@ -39,6 +39,8 @@ export async function optimizeForWeb(image: Sharp, options: OptimizeForWebOption
|
||||
return pipeline.avif({ quality, effort: 4 });
|
||||
case "png":
|
||||
return pipeline.png({ compressionLevel: 9, palette: true });
|
||||
case "jxl":
|
||||
return pipeline.jxl({ quality, effort: 7 });
|
||||
default:
|
||||
throw new Error(`Unsupported format: ${format}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user