Files
photoreport/apps/api/test/render-options.test.ts
spark 3c94dabcf1
ci / rust (push) Successful in 7m6s
ci / typescript (push) Successful in 8m42s
Photo Mechanic parity: rename on arrival, uploader output options, PM variables
Photos arriving by FTP or the desktop app get a name from a template (Live Ingest "Rename as", e.g.
PS_{event}_{timesort}); the organisation sets one, an FTP login can have its own or keep camera names.
Names are unique per event and follow the photo to another event; deliveries use them as {originalName}.
Delivery targets get Photo Mechanic's uploader options (size, quality, sharpen, ppi, EXIF, sRGB), can be
edited and duplicated, and a Cofina preset. Templates accept PM's {iptcyear4} {iptcmonth0} {iptcday0}
{datesort} {timesort} and {initials}.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 02:32:50 +01:00

33 lines
1.6 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 { renderDelivery } from "../src/delivery/render.js";
describe("delivery output options (Photo Mechanic's uploader)", () => {
let dir: string;
let original: string;
beforeAll(async () => {
dir = await mkdtemp(path.join(tmpdir(), "pr-out-"));
original = path.join(dir, "in.jpg");
await writeFile(original, await sharp({ create: { width: 5000, height: 3000, channels: 3, background: "#808080" } }).jpeg().withExif({ IFD0: { Make: "Canon", Model: "Canon EOS R3" } }).toBuffer());
});
afterAll(async () => {
await rm(dir, { recursive: true, force: true });
await exiftool.end();
});
it("fits the box, writes 300 ppi, and keeps or drops the camera EXIF", async () => {
const keep = path.join(dir, "keep.jpg");
await writeFile(keep, await renderDelivery(original, { headline: "Golo" }, { longEdge: 3500, quality: 80, sharpen: true, dpi: 300, exif: true }));
const k = await exiftool.read(keep);
expect([k.ImageWidth, k.ImageHeight, k.XResolution, k.Model, k.Headline]).toEqual([3500, 2100, 300, "Canon EOS R3", "Golo"]);
const drop = path.join(dir, "drop.jpg");
await writeFile(drop, await renderDelivery(original, { headline: "Golo" }, { longEdge: 3500, quality: 80, dpi: 200, exif: false }));
const d = await exiftool.read(drop);
expect([d.XResolution, d.Model, d.Headline]).toEqual([200, undefined, "Golo"]);
});
});