Skip to content

fix(printandplay): reduce PDF size — JPEG Q=85 + skip CMYK - #277

Merged
jsboige merged 1 commit into
masterfrom
fix/printandplay-pdf-size-reduction
May 16, 2026
Merged

fix(printandplay): reduce PDF size — JPEG Q=85 + skip CMYK#277
jsboige merged 1 commit into
masterfrom
fix/printandplay-pdf-size-reduction

Conversation

@jsboige

@jsboige jsboige commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Convert card images to JPEG Q=85 before embedding in Print&Play PDFs (new ConvertToJpeg helper in PdfManager.cs)
  • Set ConvertToCmyk = false on Print&Play CardSets only (Rules, Fallacies, Memo, Scenarii) — CMYK is for professional print, not home printing
  • Other card types (Tarot, Poker, A0, Thumbnails) retain ConvertToCmyk = true

Problem

Tarot Print&Play A4 PDFs were 223 MB, exceeding Edge PDFium's ~256 MB memory limit. This made them unusable in browser-based PDF viewers.

Expected Result

PDFs reduced from ~223 MB to ~15-30 MB (JPEG compression + no CMYK colorspace expansion).

Test plan

  • dotnet build — 0 errors, 19 warnings (pre-existing)
  • dotnet test — 120 pass / 0 fail / 5 skip (stable)
  • Pipeline regeneration to produce new Print&Play PDFs
  • Compare sizes: before ~223 MB → after ~15-30 MB
  • Visual spot-check: card image quality still acceptable at JPEG Q=85

Closes #251

🤖 Generated with Claude Code

Tarot Print&Play A4 PDFs were 223 MB, exceeding Edge PDFium's ~256 MB
memory limit. Two changes bring this down to ~15-30 MB:

- Convert card images to JPEG Q=85 before embedding in Print&Play PDFs
  (new ConvertToJpeg helper in PdfManager.cs using Magick.NET)
- Set ConvertToCmyk = false on Print&Play CardSets only (Rules, Fallacies,
  Memo, Scenarii) — CMYK is for professional print, not home printing

Other card types (Tarot, Poker, A0, Thumbnails) retain CMYK=true.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jsboige

jsboige commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

ai-01 review — LGTM, prêt à merger

Note : gh pr review --approve rejeté car même identité GitHub que l'auteur (Can not approve your own pull request). Comment substitute.

Diff review (clean) :

  • PdfManager.cs (+17) : ConvertToJpeg(byte[], int) helper avec MagickImage, Q=85, applied Front+Back avant embed Print&Play ✅
  • WebBasedGeneratorConfig.cs (-4/+4) : ConvertToCmyk = false sur 4 CardSets Print&Play (Rules, Fallacies, Memo, Scenarii) — CMYK reste sur Tarot/Poker/A0/Thumbnails (print pro) ✅
  • Tests : 120 pass / 0 fail / 5 skip, build clean ✅

Defensive design : try/catch { return imageData; } → no pipeline crash si MagickImage failure. Bonne pratique.

Cohérence avec design A+B décidé cycle 3 : ✅ exact

Follow-up non-bloquant (PR ultérieure si on rencontre le cas) :

  • Le catch silencieux masque un échec → régression silencieuse à 223 MB. Suggérer Logger.LogWarning dans le catch.

Validation post-merge requise (rapide, ~5-10min vs 25min full) :

  • Pipeline regen Print&Play only (Mode = WebBasedImageGeneration | QuestPdfGeneration suffit, Mindmapper inutile)
  • Mesure taille : objectif 222 MB → 15-30 MB
  • Visual spot-check 1-2 cartes pour vérifier que JPEG Q=85 reste acceptable

@jsboige — feu vert pour merge.

@jsboige
jsboige merged commit 71d16fa into master May 16, 2026
1 check passed
jsboige added a commit that referenced this pull request May 16, 2026
…282)

PR #277 hardcoded RGB JPEG for Print&Play, degrading printer output.
This refactor uses the existing UseDebugParams/UseReleaseParams pattern:

- DocumentCardSet: add ConvertToCmykDebug/Release + GetConvertToCmyk(config)
  Debug=false (Edge preview), Release=true (printer quality)
- ImageHelper: use GetConvertToCmyk(config) instead of ConvertToCmyk
- PdfManager: JPEG Q=85 only in Debug mode, PNG lossless in Release
- Remove hardcoded ConvertToCmyk=false from 4 Print&Play CardSets

| Build       | Print&Play output       | Tarot FR size |
|-------------|-------------------------|---------------|
| dotnet run  | RGB JPEG Q=85           | ~71 MB        |
| -c Release  | CMYK PNG lossless       | ~222 MB       |

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@jsboige
jsboige deleted the fix/printandplay-pdf-size-reduction branch June 1, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(print&play): Tarot Print&Play PDF corrupted / cannot open in Edge

1 participant