feat: add AVIF output format support across 6 remaining tools (#85)

Closes #73

AVIF was already supported in the core engine, convert, compress,
optimize-for-web, upscale, erase-object, svg-to-raster, and
pdf-to-image tools. This adds AVIF as an output format option to
the 6 tools that were missing it: split, collage, stitch,
image-to-base64, noise-removal, and red-eye-removal.

For each tool, both the frontend format selector (with quality
slider for AVIF's lossy encoding) and the backend Zod schema +
Sharp .avif() encoding were updated. AVIF defaults: quality from
the user slider, effort 4 (balanced encode speed).

Also fixes pre-existing Biome formatting violations in 5 files
that were blocking a clean lint pass.
This commit is contained in:
Ashim
2026-04-21 23:34:48 +08:00
committed by GitHub
parent 7d422c2fd0
commit ba26ea4bc7
13 changed files with 49 additions and 26 deletions
+5 -1
View File
@@ -23,7 +23,7 @@ const settingsSchema = z.object({
.string()
.regex(/^#[0-9a-fA-F]{6}$/)
.default("#FFFFFF"),
format: z.enum(["png", "jpeg", "webp"]).default("png"),
format: z.enum(["png", "jpeg", "webp", "avif"]).default("png"),
quality: z.number().min(1).max(100).default(90),
});
@@ -200,6 +200,8 @@ export function registerStitch(app: FastifyInstance) {
pipeline = pipeline.jpeg({ quality: settings.quality });
} else if (settings.format === "webp") {
pipeline = pipeline.webp({ quality: settings.quality });
} else if (settings.format === "avif") {
pipeline = pipeline.avif({ quality: settings.quality, effort: 4 });
} else {
pipeline = pipeline.png();
}
@@ -230,6 +232,8 @@ export function registerStitch(app: FastifyInstance) {
.toBuffer();
} else if (settings.format === "webp") {
result = await sharp(result).webp({ quality: settings.quality }).toBuffer();
} else if (settings.format === "avif") {
result = await sharp(result).avif({ quality: settings.quality, effort: 4 }).toBuffer();
}
}