fix: AVIF sidecar crash, edit-metadata silent no-op, passport batch blank images, color-palette hex overflow, OCR log noise

- Convert all AI bridge inputs to PNG before writing to disk so PIL can
  read AVIF/WebP/TIFF (7 bridge files; face-detection and OCR already
  had this pattern)
- Add title/author aliases to edit-metadata schema so common field names
  actually write EXIF tags instead of being silently stripped by Zod
- Port extend/pad crop logic from passport-photo single endpoint to the
  batch pipeline so crop regions extending beyond the image get filled
  with background color instead of producing all-white output
- Clamp quantized color channels to 255 in color-palette to prevent
  Math.round(255/16)*16=256 from producing invalid hex like #100100100
- Compare OCR fallback warning against expected engine name per tier
  instead of comparing engine name against tier name (always mismatch)
This commit is contained in:
ashim-hq
2026-04-21 23:54:25 +08:00
parent 0b8e0bf774
commit 9a015c8501
12 changed files with 86 additions and 36 deletions
+9 -2
View File
@@ -137,6 +137,8 @@ export async function writeMetadata(
/** Settings shape that buildTagArgs accepts */
export interface EditMetadataSettings {
title?: string;
author?: string;
artist?: string;
copyright?: string;
imageDescription?: string;
@@ -165,11 +167,16 @@ export interface EditMetadataSettings {
export function buildTagArgs(settings: EditMetadataSettings): string[] {
const args: string[] = [];
// Common aliases
const artist = settings.artist || settings.author;
const description = settings.imageDescription || settings.title;
// Basic EXIF fields
if (settings.artist) args.push(`-Artist=${settings.artist}`);
if (artist) args.push(`-Artist=${artist}`);
if (settings.copyright) args.push(`-Copyright=${settings.copyright}`);
if (settings.imageDescription) args.push(`-ImageDescription=${settings.imageDescription}`);
if (description) args.push(`-ImageDescription=${description}`);
if (settings.software) args.push(`-Software=${settings.software}`);
if (settings.title) args.push(`-XMP:Title=${settings.title}`);
// Date fields
if (settings.dateTime) args.push(`-ModifyDate=${settings.dateTime}`);