Select tool (S): lasso picks ink strokes and images that lie entirely inside the loop, a tap picks one object. Move, uniform resize, nudge, delete, recolour, copy/cut/paste/duplicate, each one undo step. Holding the pen's barrel button lassoes with any tool (Settings > Pen & touch). Copying also writes a PNG of the selection to the system clipboard. Images come in by paste, drop, the Insert image button or the page menu. They are capped at 2400 px, stored as PNG/JPEG by content hash in a new IndexedDB store, drawn between the markdown and the ink, and written to the PDF both visibly and as papure/assets + per-page images.json. Dark pages now invert each layer except images, so images keep their colours; the inverted ink layer is screen-blended so highlighted text stays bright. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UcbKnqfprs8hMkTVsYx1dh
25 lines
1,022 B
TypeScript
25 lines
1,022 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { imageKind } from '$lib/pdf/format';
|
|
import { candidateKinds, fitScale } from './normalize';
|
|
|
|
describe('image normalisation', () => {
|
|
it('caps the long edge', () => {
|
|
expect(fitScale(1200, 800)).toBe(1);
|
|
expect(fitScale(4800, 1200)).toBe(0.5);
|
|
expect(fitScale(1000, 9600)).toBe(0.25);
|
|
});
|
|
|
|
it('keeps transparency in PNG and JPEGs as JPEG', () => {
|
|
expect(candidateKinds('png', true)).toEqual(['png']);
|
|
expect(candidateKinds(null, true)).toEqual(['png']);
|
|
expect(candidateKinds('jpeg', false)).toEqual(['jpeg']);
|
|
expect(candidateKinds('png', false)).toEqual(['png', 'jpeg']);
|
|
expect(candidateKinds(null, false)).toEqual(['png', 'jpeg']); // e.g. WebP
|
|
});
|
|
|
|
it('sniffs PNG and JPEG', () => {
|
|
expect(imageKind(new Uint8Array([0x89, 0x50, 0x4e, 0x47, 13, 10]))).toBe('png');
|
|
expect(imageKind(new Uint8Array([0xff, 0xd8, 0xff, 0xe0]))).toBe('jpeg');
|
|
expect(imageKind(new Uint8Array([0x52, 0x49, 0x46, 0x46]))).toBeNull(); // RIFF (WebP)
|
|
});
|
|
});
|