- POST /v1/orgs/:orgId/uploads: one JPEG per request through the FTP pipeline (dedupe, EXIF, routing or an explicit event, previews, live message); the web library imports by button or drag and drop, 4 at a time with progress - Ingest reads the IPTC already in a file (XMP first; IIM from Lightroom/Photo Mechanic on the Mac is Mac Roman without a charset flag and is repaired) and keeps it next to ours; the info panel shows it and can reuse its Title as the players - Tokens for client-made connections are refreshed a minute before they expire Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
43 lines
2.2 KiB
TypeScript
43 lines
2.2 KiB
TypeScript
import { exiftool } from "exiftool-vendored";
|
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import sharp from "sharp";
|
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import { readEmbeddedIptc, repairMacRoman } from "../src/ingest/embedded.js";
|
|
|
|
describe("IPTC already in incoming files", () => {
|
|
let dir: string;
|
|
beforeAll(async () => {
|
|
dir = await mkdtemp(path.join(tmpdir(), "pr-emb-"));
|
|
});
|
|
afterAll(async () => {
|
|
await exiftool.end();
|
|
await rm(dir, { recursive: true, force: true });
|
|
});
|
|
|
|
async function file(name: string, args: string[]): Promise<string> {
|
|
const p = path.join(dir, name);
|
|
await writeFile(p, await sharp({ create: { width: 64, height: 48, channels: 3, background: "#456" } }).jpeg().toBuffer());
|
|
await exiftool.write(p, {}, { writeArgs: ["-overwrite_original", ...args] });
|
|
return p;
|
|
}
|
|
|
|
it("repairs Mac Roman text written without a charset flag (Lightroom/Photo Mechanic on the Mac)", async () => {
|
|
expect(repairMacRoman("Pavilh\u008Bo da Escola EB 2/3 Andr\u008E Soares")).toBe("Pavilhão da Escola EB 2/3 André Soares");
|
|
const p = await file("macroman.jpg", ["-charset", "iptc=MacRoman", "-IPTC:Sub-location=Pavilhão da Escola EB 2/3 André Soares", "-IPTC:ObjectName=João Gonçalves", "-IPTC:Keywords=ANDEBOL"]);
|
|
expect(await readEmbeddedIptc(p)).toEqual({ location: "Pavilhão da Escola EB 2/3 André Soares", title: "João Gonçalves", keywords: ["ANDEBOL"] });
|
|
});
|
|
|
|
it("prefers XMP, which is always UTF-8", async () => {
|
|
const p = await file("xmp.jpg", ["-XMP-dc:Title=Nome do Jogador", "-XMP-iptcExt:Event=ABC Braga x CDE Gil Eanes", "-XMP-iptcCore:Location=Pavilhão", "-XMP-iptcExt:PersonInImage=Rui Silva"]);
|
|
expect(await readEmbeddedIptc(p)).toEqual({ title: "Nome do Jogador", event: "ABC Braga x CDE Gil Eanes", location: "Pavilhão", personsShown: ["Rui Silva"] });
|
|
});
|
|
|
|
it("returns nothing for a bare camera file", async () => {
|
|
const p = path.join(dir, "bare.jpg");
|
|
await writeFile(p, await sharp({ create: { width: 8, height: 8, channels: 3, background: "#000" } }).jpeg().toBuffer());
|
|
expect(await readEmbeddedIptc(p)).toEqual({});
|
|
});
|
|
});
|