Initial commit: Luminary photo catalog and RAW editor
Browser-based photo catalog with an optional team server (SQLite + LibRaw). Local database, uploaded photos, build output and dependencies are gitignored. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { srgbProfile } from './icc';
|
||||
|
||||
describe('sRGB ICC profile', () => {
|
||||
it('is a self-consistent v2 RGB display profile', () => {
|
||||
const profile = srgbProfile();
|
||||
const view = new DataView(profile.buffer);
|
||||
expect(profile.length).toBeGreaterThan(2000);
|
||||
expect(view.getUint32(0, false)).toBe(profile.length);
|
||||
expect(String.fromCharCode(...profile.subarray(36, 40))).toBe('acsp');
|
||||
expect(String.fromCharCode(...profile.subarray(16, 20))).toBe('RGB ');
|
||||
expect(String.fromCharCode(...profile.subarray(20, 24))).toBe('XYZ ');
|
||||
expect(view.getUint32(128, false)).toBeGreaterThan(5);
|
||||
});
|
||||
|
||||
it('carries a readable description for colour-managed viewers', () => {
|
||||
const profile = srgbProfile();
|
||||
const view = new DataView(profile.buffer);
|
||||
const count = view.getUint32(128, false);
|
||||
let descriptionAt = -1;
|
||||
for (let index = 0; index < count; index++) {
|
||||
const at = 132 + index * 12;
|
||||
if (String.fromCharCode(...profile.subarray(at, at + 4)) === 'desc') {
|
||||
descriptionAt = view.getUint32(at + 4, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(descriptionAt).toBeGreaterThan(0);
|
||||
expect(String.fromCharCode(...profile.subarray(descriptionAt, descriptionAt + 4))).toBe('desc');
|
||||
});
|
||||
|
||||
it('uses the sampled sRGB transfer curve rather than gamma 2.2', () => {
|
||||
const profile = srgbProfile();
|
||||
const view = new DataView(profile.buffer);
|
||||
const count = view.getUint32(128, false);
|
||||
let curveAt = -1;
|
||||
for (let index = 0; index < count; index++) {
|
||||
const at = 132 + index * 12;
|
||||
if (String.fromCharCode(...profile.subarray(at, at + 4)) === 'rTRC') {
|
||||
curveAt = view.getUint32(at + 4, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(curveAt).toBeGreaterThan(0);
|
||||
expect(String.fromCharCode(...profile.subarray(curveAt, curveAt + 4))).toBe('curv');
|
||||
expect(view.getUint32(curveAt + 8, false)).toBe(1024);
|
||||
expect(view.getUint16(curveAt + 12, false)).toBe(0);
|
||||
expect(view.getUint16(curveAt + 12 + 2 * 1023, false)).toBe(65535);
|
||||
const midpoint = view.getUint16(curveAt + 12 + 2 * 512, false);
|
||||
expect(midpoint).toBeGreaterThan(13000);
|
||||
expect(midpoint).toBeLessThan(15000);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user