Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/export_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def _render_verified_payload(
producer="Comic Sol 1.0",
creationDate=False,
modDate=False,
quality=95,
)
# Windows rejects fsync on a read-only descriptor.
with temporary_path.open("rb+") as handle:
Expand Down
18 changes: 17 additions & 1 deletion tests/test_export_pdf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import hashlib
import io
import random
import re
import shutil
import sys
Expand All @@ -8,7 +9,7 @@
from pathlib import Path
from unittest import mock

from PIL import Image, UnidentifiedImageError
from PIL import Image, ImageOps, UnidentifiedImageError

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "scripts"))
Expand Down Expand Up @@ -101,6 +102,21 @@ def test_pdf_records_150_dpi_within_round_trip_tolerance(self):
self.assertAlmostEqual(150.0, effective_x, delta=0.2)
self.assertAlmostEqual(150.0, effective_y, delta=0.2)

def test_detailed_page_survives_pdf_fidelity_gate(self):
noise = Image.frombytes(
"L", (320, 480), random.Random(0).randbytes(320 * 480)
)
page = ImageOps.colorize(
noise.resize((1600, 2400), Image.Resampling.LANCZOS),
(4, 12, 28),
(230, 150, 70),
)
noise.close()
page.save(self.project / "pages/page-001.png")
page.close()

self.assertTrue(export_pdf(self.project).is_file())

def test_custom_output_path_and_cli_are_supported(self):
custom = self.project / "deliverables/custom.pdf"
self.assertEqual(custom, export_pdf(self.project, custom))
Expand Down
Loading