fix(cover): round page count to even before computing spine width

Amazon rounds odd page counts up to the next even number before
calculating spine thickness. 99 pages → 100 effective pages gives
0.2347 in (5.96 mm) instead of 0.2324 in (5.90 mm).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 09:25:58 +02:00
parent 42b31bb661
commit 0e2ad13aaf
2 changed files with 3 additions and 2 deletions
+3 -2
View File
@@ -90,8 +90,9 @@ async function generate() {
console.warn('Run `pnpm build` first for an accurate spine width.\n');
}
// Compute dimensions
const spineWidth = pageCount * SPINE_PER_PAGE;
// Amazon rounds odd page counts up to even before computing spine width
const effectivePageCount = pageCount % 2 === 0 ? pageCount : pageCount + 1;
const spineWidth = effectivePageCount * SPINE_PER_PAGE;
const totalWidth = BLEED_IN + TRIM_W_IN + spineWidth + TRIM_W_IN + BLEED_IN;
const totalHeight = BLEED_IN + TRIM_H_IN + BLEED_IN;