Release Image Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createOutputName } from "../../src/image/filenames";
|
||||
import {
|
||||
createProcessingReport,
|
||||
serializeReport,
|
||||
} from "../../src/image/reports";
|
||||
import {
|
||||
DEFAULT_OUTPUT,
|
||||
DEFAULT_RECIPE,
|
||||
type ImageInspection,
|
||||
} from "../../src/image/types";
|
||||
|
||||
const inspection: ImageInspection = {
|
||||
format: "jpeg",
|
||||
mimeType: "image/jpeg",
|
||||
extension: "jpg",
|
||||
width: 10,
|
||||
height: 20,
|
||||
orientedWidth: 20,
|
||||
orientedHeight: 10,
|
||||
orientation: 6,
|
||||
animated: false,
|
||||
hasAlpha: false,
|
||||
bitsPerChannel: 8,
|
||||
colorDescription: "Three-component JPEG",
|
||||
metadata: {
|
||||
exif: true,
|
||||
xmp: false,
|
||||
icc: true,
|
||||
comments: false,
|
||||
text: false,
|
||||
physicalDimensions: false,
|
||||
multiPicture: false,
|
||||
},
|
||||
headerBytesInspected: 100,
|
||||
warnings: [],
|
||||
};
|
||||
|
||||
describe("image output identity and reports", () => {
|
||||
it("normalizes unsafe output names", () => {
|
||||
expect(createOutputName("../bad:name?.jpeg", "webp")).toBe(
|
||||
"_bad_name_-edited.webp",
|
||||
);
|
||||
expect(createOutputName(".jpg", "png")).toBe("image-edited.png");
|
||||
});
|
||||
|
||||
it("states metadata and color limitations explicitly", () => {
|
||||
const report = createProcessingReport({
|
||||
file: new File([Uint8Array.of(1, 2)], "source.jpg", {
|
||||
type: "image/jpeg",
|
||||
}),
|
||||
inspection,
|
||||
recipe: DEFAULT_RECIPE,
|
||||
output: DEFAULT_OUTPUT,
|
||||
outputName: "source-edited.png",
|
||||
outputBytes: 123,
|
||||
outputMimeType: "image/png",
|
||||
outputWidth: 20,
|
||||
outputHeight: 10,
|
||||
});
|
||||
expect(report.metadataPolicy.copied).toBe(false);
|
||||
expect(report.colorPolicy.profilePreserved).toBe(false);
|
||||
expect(report.limitations.join(" ")).toMatch(/does not promise privacy/u);
|
||||
expect(serializeReport(report)).toMatch(/"schemaVersion": 1/u);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user