proof-pdf 0.3.6__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/PKG-INFO +4 -1
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/README.md +3 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/pyproject.toml +1 -1
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/colour.py +146 -6
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/contrast.py +3 -3
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/paint.py +54 -35
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/resolution.py +8 -5
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/spaces.py +30 -1
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/spots.py +2 -2
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/structure.py +4 -6
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/core.py +2 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/extract.py +9 -21
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/inventory.py +7 -3
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/build_pdfs.py +3 -1
- proof_pdf-0.3.7/tests/fixtures/pdfs/bleed-full.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/bleed-short.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-image-profile.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-pattern.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-profile-mismatch.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-shading.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-stroke-only.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/cmyk-vector.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/colortbl-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/colortbl-default-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/colortbl-rgb-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/figure-cmyk-pdf.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/figure-rgb-pdf.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/gray-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/hairline-stroke.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/hyperref-colorlinks.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/hyperref-links.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/image-in-tikz.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/image-resolution-ok.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/ink-over-limit.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/ink-within-limit.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/inline-images.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/low-resolution-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/mask-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/mixed-rgb-profiles.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pdfa-2b-rgb-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pdfa-2b-rgb.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pdfx-x4-cmyk-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pdfx-x4-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pdfx-x4-rgb-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pgfplots-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pgfplots-default-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/pgfplots-rgb-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/rgb-image-device.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/rgb-image-profile.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/rgb-pattern.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/rgb-vector.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/rgba-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/shading-pattern.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/spot-colour.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/spot-conflict.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/spot-image.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/stroke-ok.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tcolorbox-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tcolorbox-default-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tcolorbox-rgb-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/text-black-default.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/text-black-rgb.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/text-k-only-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/text-rich-black-small.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-cmyk-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-default-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-opacity-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-opacity-group-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-opacity-group-wrong.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-pattern-cmyk-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-rgb-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/tikz-shading-cmyk-doc.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-cmyk-option.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-default.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-dvipsnames-rgb.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-dvipsnames.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-gray-option.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-mix-cmyk.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-mix-default.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-models.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-rgb-option.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/pdfs/xcolor-svgnames.pdf +0 -0
- proof_pdf-0.3.7/tests/fixtures/samples/README.md +28 -0
- proof_pdf-0.3.7/tests/fixtures/samples/SOURCES.json +71 -0
- proof_pdf-0.3.7/tests/fixtures/samples/bleed-full.tex +12 -0
- proof_pdf-0.3.7/tests/fixtures/samples/bleed-short.tex +12 -0
- proof_pdf-0.3.7/tests/fixtures/samples/build.py +183 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-image-profile.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-image.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-pattern.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-profile-mismatch.tex +12 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-shading.tex +9 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-stroke-only.tex +9 -0
- proof_pdf-0.3.7/tests/fixtures/samples/cmyk-vector.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/colortbl-cmyk.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/colortbl-default-doc.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/colortbl-rgb-doc.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/expected.toml +355 -0
- proof_pdf-0.3.7/tests/fixtures/samples/figure-cmyk-pdf.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/figure-rgb-pdf.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/gray-image.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/hairline-stroke.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/hyperref-colorlinks.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/hyperref-links.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/image-in-tikz.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/image-resolution-ok.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/ink-over-limit.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/ink-within-limit.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/inline-images.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/low-resolution-image.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/mask-image.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/mixed-rgb-profiles.tex +11 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfa-2b-rgb-image.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfa-2b-rgb-image.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfa-2b-rgb.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfa-2b-rgb.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfraw.tex +44 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-cmyk-image.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-cmyk-image.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-cmyk.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-cmyk.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-rgb-image.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pdfx-x4-rgb-image.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pgfplots-cmyk.tex +14 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pgfplots-default-doc.tex +14 -0
- proof_pdf-0.3.7/tests/fixtures/samples/pgfplots-rgb-doc.tex +14 -0
- proof_pdf-0.3.7/tests/fixtures/samples/rgb-image-device.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/rgb-image-profile.tex +9 -0
- proof_pdf-0.3.7/tests/fixtures/samples/rgb-pattern.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/rgb-vector.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/rgba-image.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/shading-pattern.tex +11 -0
- proof_pdf-0.3.7/tests/fixtures/samples/spot-colour.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/spot-conflict.tex +9 -0
- proof_pdf-0.3.7/tests/fixtures/samples/spot-image.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/stroke-ok.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tcolorbox-cmyk.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tcolorbox-default-doc.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tcolorbox-rgb-doc.tex +10 -0
- proof_pdf-0.3.7/tests/fixtures/samples/text-black-default.tex +6 -0
- proof_pdf-0.3.7/tests/fixtures/samples/text-black-rgb.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/text-k-only-cmyk.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/text-rich-black-small.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-cmyk-doc.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-default-doc.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-opacity-cmyk.tex +11 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-opacity-group-cmyk.tex +15 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-opacity-group-cmyk.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-opacity-group-wrong.tex +15 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-opacity-group-wrong.xmpdata +4 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-pattern-cmyk-doc.tex +12 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-rgb-doc.tex +13 -0
- proof_pdf-0.3.7/tests/fixtures/samples/tikz-shading-cmyk-doc.tex +11 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-cmyk-option.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-default.tex +8 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-dvipsnames-rgb.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-dvipsnames.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-gray-option.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-mix-cmyk.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-mix-default.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-models.tex +15 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-rgb-option.tex +7 -0
- proof_pdf-0.3.7/tests/fixtures/samples/xcolor-svgnames.tex +7 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/suites/expected.toml +2 -0
- proof_pdf-0.3.7/tests/test_proof_pdf/_samples.py +10 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_colour.py +174 -2
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_contrast.py +3 -19
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_fixtures_current.py +2 -1
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_resolution.py +8 -0
- proof_pdf-0.3.7/tests/test_proof_pdf/test_samples.py +57 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/LICENSE +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/NOTICE +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/__init__.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/__init__.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/config.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/content.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/deltae.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/fonts.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/functions.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/interactive.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/previews.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/proc.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/tables.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/tagged.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/text.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/vector.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/verapdf.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/_internal/xmp.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/cli.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/config.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/crop.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/layout.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/models.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/preview.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/py.typed +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/src/proof_pdf/texlog.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/black-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/corrupt.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/cyan-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/edge-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/embedded-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/good.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/hairline.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/heavy-ink.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/high-contrast.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/low-contrast.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/low-dpi-image.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/no-bleed.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/no-output-intent.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/notdef-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/plain.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/registration-spot.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/rgb-image.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/rich-black-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/small-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/spot-ink.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/three-pages.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/transparent-matching.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/transparent-mismatch.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/transparent-undeclared.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/two-sizes.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/type3-text.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/white-overprint.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/pdfs/wrong-size.pdf +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/fixtures/suites/README.md +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/__init__.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/conftest.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_bleed.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_cli.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_config.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_content.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_core.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_crop.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_deltae.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_extract.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_integration.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_inventory.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_load_profile.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_paint.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_preview.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_proc.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_public_api.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_structure.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_suites.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_texlog.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_text.py +0 -0
- {proof_pdf-0.3.6 → proof_pdf-0.3.7}/tests/test_proof_pdf/test_verapdf.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: proof-pdf
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.7
|
|
4
4
|
Summary: Hold print PDFs to PDF/X-4 and PDF/A: veraPDF, page boxes, geometry, ink and image resolution.
|
|
5
5
|
Keywords: pdf,pdf/x-4,pdf/a,verapdf,prepress,print,preflight,ghostscript,lualatex
|
|
6
6
|
Author-Email: Ilja Orlovs <ilja@release.art>
|
|
@@ -50,6 +50,9 @@ Open-source pieces of a print-on-demand pipeline, extracted from production use.
|
|
|
50
50
|
overprint and rich-black small text (`--no-colour`). Overprinting 100% K text is fine; overprint on anything else is flagged,
|
|
51
51
|
and **white that overprints is an error** (it adds no ink, so it vanishes on press). A page that uses transparency must blend
|
|
52
52
|
in the output intent's colour space (a mismatch is an error, an undeclared space a warning).
|
|
53
|
+
- **Spot inks and ICC profiles**: one ink defined two ways in the same space is an error (`spot-definition`); an invalid ICC profile, or a
|
|
54
|
+
profile that disagrees with its colour space, is an error, and so is a mix of RGB profiles in an RGB job (`icc-profile`); a CMYK
|
|
55
|
+
profile other than the output intent's is a warning.
|
|
53
56
|
- **RGB proofing** (opt-in, `--colour-mode rgb`): for a screen job, CMYK images, fills, strokes, shadings and patterns and a CMYK output intent are errors, spot colours a warning;
|
|
54
57
|
total ink, overprint and rich-black checks are skipped. Save it as a profile: `[profiles.web.verify]` with `colour-mode = "rgb"` and `pdfx = false`, chosen with `proof-pdf --profile web verify`.
|
|
55
58
|
- **K-only text** (opt-in, `--k-only-text`): text painted with any ink but K (a four-colour build, RGB, a spot or a pattern) is an error.
|
|
@@ -24,6 +24,9 @@ Open-source pieces of a print-on-demand pipeline, extracted from production use.
|
|
|
24
24
|
overprint and rich-black small text (`--no-colour`). Overprinting 100% K text is fine; overprint on anything else is flagged,
|
|
25
25
|
and **white that overprints is an error** (it adds no ink, so it vanishes on press). A page that uses transparency must blend
|
|
26
26
|
in the output intent's colour space (a mismatch is an error, an undeclared space a warning).
|
|
27
|
+
- **Spot inks and ICC profiles**: one ink defined two ways in the same space is an error (`spot-definition`); an invalid ICC profile, or a
|
|
28
|
+
profile that disagrees with its colour space, is an error, and so is a mix of RGB profiles in an RGB job (`icc-profile`); a CMYK
|
|
29
|
+
profile other than the output intent's is a warning.
|
|
27
30
|
- **RGB proofing** (opt-in, `--colour-mode rgb`): for a screen job, CMYK images, fills, strokes, shadings and patterns and a CMYK output intent are errors, spot colours a warning;
|
|
28
31
|
total ink, overprint and rich-black checks are skipped. Save it as a profile: `[profiles.web.verify]` with `colour-mode = "rgb"` and `pdfx = false`, chosen with `proof-pdf --profile web verify`.
|
|
29
32
|
- **K-only text** (opt-in, `--k-only-text`): text painted with any ink but K (a four-colour build, RGB, a spot or a pattern) is an error.
|
|
@@ -26,18 +26,19 @@ a failure by the caller, not silently skipped); the rest read the
|
|
|
26
26
|
|
|
27
27
|
import asyncio
|
|
28
28
|
import collections.abc
|
|
29
|
+
import io
|
|
29
30
|
import logging
|
|
30
31
|
import pathlib
|
|
31
32
|
import shutil
|
|
32
33
|
import tempfile
|
|
33
34
|
|
|
34
35
|
import pikepdf
|
|
35
|
-
from PIL import Image, ImageMath
|
|
36
|
+
from PIL import Image, ImageCms, ImageMath
|
|
36
37
|
|
|
37
|
-
from ..models import Finding, Severity
|
|
38
|
-
from . import proc
|
|
38
|
+
from ..models import ColourMode, Finding, Severity
|
|
39
|
+
from . import proc, spots
|
|
39
40
|
from .paint import Fill, Walker, paint_events
|
|
40
|
-
from .spaces import CMYK, GRAY, RGB, classify_colour_space, intent_family
|
|
41
|
+
from .spaces import CMYK, GRAY, RGB, classify_colour_space, intent_family, output_intents, reachable
|
|
41
42
|
|
|
42
43
|
logger = logging.getLogger(__name__)
|
|
43
44
|
|
|
@@ -325,6 +326,145 @@ def _paint_in(page: pikepdf.Page, family: str) -> tuple[set[str], set[str], set[
|
|
|
325
326
|
return images, colours, spots
|
|
326
327
|
|
|
327
328
|
|
|
329
|
+
# --------------------------------------------------------- spot definitions ----
|
|
330
|
+
def check_spot_definitions(pdf: pikepdf.Pdf) -> list[Finding]:
|
|
331
|
+
"""Flag a spot ink defined more than one way: same name, different alternate space or full-tint look.
|
|
332
|
+
|
|
333
|
+
The name is what a printer matches to an ink, but the alternate is what proofs and the screen show. Two
|
|
334
|
+
definitions of PANTONE 165 C mean two different oranges in the proof, and usually mean one file came from another
|
|
335
|
+
workflow. Only definitions whose tint transform could be evaluated are compared, to within 1%, and only against
|
|
336
|
+
definitions in the same alternate space.
|
|
337
|
+
"""
|
|
338
|
+
# ponytail: alternates in different spaces (Black as Gray 0 vs CMYK 0/0/0/100) are not compared, as that needs a
|
|
339
|
+
# conversion; add one if mixed-space definitions turn out to matter.
|
|
340
|
+
definitions: dict[tuple[tuple[str, ...], str | None], dict[tuple, str]] = {}
|
|
341
|
+
for obj in reachable(pdf):
|
|
342
|
+
if not (isinstance(obj, pikepdf.Array) and len(obj) >= 4 and str(obj[0]) in ("/Separation", "/DeviceN")):
|
|
343
|
+
continue
|
|
344
|
+
try:
|
|
345
|
+
spot = spots.read(obj)
|
|
346
|
+
except IndexError, KeyError, TypeError, ValueError, pikepdf.PdfError:
|
|
347
|
+
continue
|
|
348
|
+
if spot.alternate is None or any(n in ("All", "None") for n in spot.names):
|
|
349
|
+
continue
|
|
350
|
+
look = (spot.alternate_space, tuple(round(v, 2) for v in spot.alternate))
|
|
351
|
+
definitions.setdefault((spot.names, spot.alternate_space), {}).setdefault(look, f"{spot.alternate}")
|
|
352
|
+
return [
|
|
353
|
+
Finding(
|
|
354
|
+
"spot-definition",
|
|
355
|
+
Severity.ERROR,
|
|
356
|
+
f"spot ink {' + '.join(names)} is defined {len(looks)} different ways in {space}: "
|
|
357
|
+
f"{'; '.join(looks.values())}",
|
|
358
|
+
)
|
|
359
|
+
for (names, space), looks in sorted(definitions.items(), key=str)
|
|
360
|
+
if len(looks) > 1
|
|
361
|
+
]
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
# ------------------------------------------------------------ ICC profiles ----
|
|
365
|
+
# The data colour space in an ICC header (bytes 16-20) and how many components it has.
|
|
366
|
+
_ICC_SPACES = {b"GRAY": (GRAY, 1), b"RGB ": (RGB, 3), b"CMYK": (CMYK, 4), b"Lab ": ("lab", 3)}
|
|
367
|
+
_ICC_HEADER = 128
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def check_icc_profiles(pdf: pikepdf.Pdf, mode: ColourMode) -> list[Finding]:
|
|
371
|
+
"""Check the ICC profiles the file embeds for colour spaces: sound, and consistent with the job.
|
|
372
|
+
|
|
373
|
+
Every profile must be readable and its header must agree with the space's ``/N``. Then, by mode: in a CMYK job a
|
|
374
|
+
CMYK profile other than the output intent's is a warning (legal in PDF/X-4, but the RIP converts through it); in an
|
|
375
|
+
RGB job every RGB profile, the output intent's included, must be the same one, since mixed working spaces shift
|
|
376
|
+
colour between objects.
|
|
377
|
+
"""
|
|
378
|
+
findings: list[Finding] = []
|
|
379
|
+
seen: dict[str, tuple[str, str]] = {} # profile digest -> (family, description)
|
|
380
|
+
for obj in reachable(pdf):
|
|
381
|
+
if not (isinstance(obj, pikepdf.Array) and len(obj) > 1 and str(obj[0]) == "/ICCBased"):
|
|
382
|
+
continue
|
|
383
|
+
try:
|
|
384
|
+
data = bytes(obj[1].read_bytes())
|
|
385
|
+
components = int(obj[1].get("/N", 0))
|
|
386
|
+
except pikepdf.PdfError, AttributeError, TypeError, ValueError:
|
|
387
|
+
findings.append(
|
|
388
|
+
Finding("icc-profile", Severity.ERROR, "an ICCBased colour space has an unreadable profile")
|
|
389
|
+
)
|
|
390
|
+
continue
|
|
391
|
+
problem, family = _icc_problem(data, components)
|
|
392
|
+
label = _icc_label(data)
|
|
393
|
+
if problem:
|
|
394
|
+
findings.append(Finding("icc-profile", Severity.ERROR, f"ICC profile {label}: {problem}"))
|
|
395
|
+
elif family is not None:
|
|
396
|
+
seen.setdefault(_profile_key(data, label), (family, label))
|
|
397
|
+
return findings + _profile_consistency(seen, _intent_profile(pdf), mode)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def _profile_consistency(
|
|
401
|
+
seen: dict[str, tuple[str, str]], intent: tuple[str, str, str] | None, mode: ColourMode
|
|
402
|
+
) -> list[Finding]:
|
|
403
|
+
"""The mode's rule over the distinct profiles *seen* and the output *intent*'s."""
|
|
404
|
+
if mode is ColourMode.RGB:
|
|
405
|
+
rgb = {d: v[1] for d, v in seen.items() if v[0] == RGB}
|
|
406
|
+
if intent is not None and intent[1] == RGB:
|
|
407
|
+
rgb.setdefault(intent[0], intent[2])
|
|
408
|
+
if len(rgb) > 1:
|
|
409
|
+
return [Finding("icc-profile", Severity.ERROR, f"the RGB job mixes {len(rgb)} RGB profiles: {_names(rgb)}")]
|
|
410
|
+
elif intent is not None and intent[1] == CMYK:
|
|
411
|
+
other = {d: v[1] for d, v in seen.items() if v[0] == CMYK and d != intent[0]}
|
|
412
|
+
if other:
|
|
413
|
+
return [
|
|
414
|
+
Finding(
|
|
415
|
+
"icc-profile",
|
|
416
|
+
Severity.WARN,
|
|
417
|
+
f"CMYK profile(s) {_names(other)} differ from the output intent {intent[2]!r}: the RIP converts",
|
|
418
|
+
)
|
|
419
|
+
]
|
|
420
|
+
return []
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def _icc_problem(data: bytes, components: int) -> tuple[str | None, str | None]:
|
|
424
|
+
"""``(problem, family)``: what is wrong with the profile bytes against ``/N``, and the family it is for."""
|
|
425
|
+
if len(data) < _ICC_HEADER or data[36:40] != b"acsp":
|
|
426
|
+
return "is not a valid ICC profile", None
|
|
427
|
+
space = _ICC_SPACES.get(data[16:20])
|
|
428
|
+
if space is None:
|
|
429
|
+
return None, None
|
|
430
|
+
if space[1] != components:
|
|
431
|
+
return f"is a {data[16:20].decode().strip()} profile but the colour space declares /N {components}", None
|
|
432
|
+
return None, space[0]
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
def _profile_key(data: bytes, label: str) -> str:
|
|
436
|
+
"""Which profile this is: its description and size. The same profile is often embedded byte-different (a rewritten
|
|
437
|
+
header or profile ID), so a content hash would call it two."""
|
|
438
|
+
return f"{label}:{len(data)}"
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def _icc_label(data: bytes) -> str:
|
|
442
|
+
try:
|
|
443
|
+
return ImageCms.getProfileDescription(ImageCms.ImageCmsProfile(io.BytesIO(data))).strip() or "(unnamed)"
|
|
444
|
+
except ImageCms.PyCMSError, OSError, AttributeError:
|
|
445
|
+
return "(unreadable)"
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def _intent_profile(pdf: pikepdf.Pdf) -> tuple[str, str, str] | None:
|
|
449
|
+
"""``(digest, family, description)`` of the first output intent's profile, or ``None``."""
|
|
450
|
+
for intent in output_intents(pdf):
|
|
451
|
+
profile = intent.get("/DestOutputProfile")
|
|
452
|
+
if profile is None:
|
|
453
|
+
continue
|
|
454
|
+
try:
|
|
455
|
+
data = bytes(profile.read_bytes())
|
|
456
|
+
except pikepdf.PdfError:
|
|
457
|
+
continue
|
|
458
|
+
space = _ICC_SPACES.get(data[16:20])
|
|
459
|
+
if space is not None:
|
|
460
|
+
return _profile_key(data, _icc_label(data)), space[0], _icc_label(data)
|
|
461
|
+
return None
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def _names(profiles: dict[str, str]) -> str:
|
|
465
|
+
return ", ".join(sorted(profiles.values()))
|
|
466
|
+
|
|
467
|
+
|
|
328
468
|
# ------------------------------------------------ rich-black small text ----
|
|
329
469
|
def check_rich_black(pdf: pikepdf.Pdf, small_text_pt: float) -> list[Finding]:
|
|
330
470
|
"""Flag small text painted in a built (rich) black on any page (advisory)."""
|
|
@@ -333,7 +473,7 @@ def check_rich_black(pdf: pikepdf.Pdf, small_text_pt: float) -> list[Finding]:
|
|
|
333
473
|
sizes = [
|
|
334
474
|
p.size
|
|
335
475
|
for p in paint_events(page)
|
|
336
|
-
if p.kind == "text" and _is_rich_black(p.
|
|
476
|
+
if p.kind == "text" and any(_is_rich_black(c) for c in p.colours()) and p.size <= small_text_pt
|
|
337
477
|
]
|
|
338
478
|
if sizes:
|
|
339
479
|
findings.append(
|
|
@@ -360,7 +500,7 @@ def check_k_only_text(pdf: pikepdf.Pdf) -> list[Finding]:
|
|
|
360
500
|
"""Flag text painted with any ink but K: a four-colour build, RGB, or a spot or pattern."""
|
|
361
501
|
findings: list[Finding] = []
|
|
362
502
|
for i, page in enumerate(pdf.pages, start=1):
|
|
363
|
-
bad = [
|
|
503
|
+
bad = [c for p in paint_events(page) if p.kind == "text" for c in p.colours() if not _is_k_only(c)]
|
|
364
504
|
if bad:
|
|
365
505
|
more = f" (and {len(bad) - 1} more runs)" if len(bad) > 1 else ""
|
|
366
506
|
findings.append(
|
|
@@ -21,7 +21,7 @@ from PIL import Image, ImageCms
|
|
|
21
21
|
from ..models import Finding, Severity
|
|
22
22
|
from . import deltae
|
|
23
23
|
from .paint import Fill, Rect, paint_events
|
|
24
|
-
from .spaces import CMYK, GRAY, RGB
|
|
24
|
+
from .spaces import CMYK, GRAY, RGB, output_intents
|
|
25
25
|
|
|
26
26
|
Lab = tuple[float, float, float]
|
|
27
27
|
|
|
@@ -90,7 +90,7 @@ def _load(data: bytes) -> ImageCms.ImageCmsProfile:
|
|
|
90
90
|
|
|
91
91
|
def _intent_profiles(pdf: pikepdf.Pdf) -> list[bytes]:
|
|
92
92
|
profiles: list[bytes] = []
|
|
93
|
-
for intent in pdf
|
|
93
|
+
for intent in output_intents(pdf):
|
|
94
94
|
stream = intent.get("/DestOutputProfile")
|
|
95
95
|
if stream is not None:
|
|
96
96
|
profiles.append(stream.read_bytes())
|
|
@@ -118,7 +118,7 @@ def measure(pdf: pikepdf.Pdf, model: ColourModel) -> list[ContrastPair]:
|
|
|
118
118
|
found: dict[tuple[Fill, Fill | None, bool], list[float]] = {}
|
|
119
119
|
grounds: list[tuple[Rect, Fill | None]] = []
|
|
120
120
|
for p in paint_events(page):
|
|
121
|
-
if p.kind in ("image", "shading"):
|
|
121
|
+
if p.kind in ("image", "inline-image", "shading"):
|
|
122
122
|
grounds.append((p.bbox or _UNBOUNDED, None))
|
|
123
123
|
elif p.kind == "path" and p.filled and p.bbox is not None:
|
|
124
124
|
grounds.append((p.bbox, p.fill if p.fill.family != "other" else None))
|
|
@@ -196,12 +196,12 @@ def _with_components(fill: Fill, args: list) -> Fill:
|
|
|
196
196
|
return fill # a tint in some other space: still not a device colour
|
|
197
197
|
|
|
198
198
|
|
|
199
|
-
def _pattern_base(space: object, resources: pikepdf.Object | None) ->
|
|
200
|
-
"""The base
|
|
199
|
+
def _pattern_base(space: object, resources: pikepdf.Object | None) -> object | None:
|
|
200
|
+
"""The base space of a ``[/Pattern base]`` space (for uncoloured patterns), else ``None``."""
|
|
201
201
|
if isinstance(space, pikepdf.Name):
|
|
202
202
|
space = lookup_resource(resources, "/ColorSpace", [space])
|
|
203
203
|
if isinstance(space, pikepdf.Array) and len(space) > 1 and str(space[0]) == "/Pattern":
|
|
204
|
-
return
|
|
204
|
+
return space[1]
|
|
205
205
|
return None
|
|
206
206
|
|
|
207
207
|
|
|
@@ -261,46 +261,59 @@ class Walker:
|
|
|
261
261
|
return self._paint_path(op, filled=False, stroked=True)
|
|
262
262
|
if name in _FILL_STROKE_PATH:
|
|
263
263
|
return self._paint_path(op, filled=True, stroked=True)
|
|
264
|
-
state = self.state
|
|
265
264
|
if name == "sh":
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
return self._shading(op)
|
|
266
|
+
if name == "INLINE IMAGE":
|
|
267
|
+
return self._inline_image(op)
|
|
268
|
+
if name == "Do":
|
|
269
|
+
return self._image(op)
|
|
270
|
+
return None
|
|
271
|
+
|
|
272
|
+
def _shading(self, op: content.Operation) -> Paint:
|
|
273
|
+
"""An ``sh``: it fills the whole clip; unclipped, its extent is unknown (it covers the page)."""
|
|
274
|
+
state = self.state
|
|
275
|
+
shading = lookup_resource(op.resources, "/Shading", op.operands)
|
|
276
|
+
space = classify_colour_space(shading.get("/ColorSpace"), op.resources) if shading is not None else None
|
|
277
|
+
if shading is not None:
|
|
278
|
+
self.spots.update(spot_names(shading.get("/ColorSpace"), op.resources))
|
|
279
|
+
return Paint(
|
|
280
|
+
"shading",
|
|
281
|
+
state.fill,
|
|
282
|
+
state.overprint,
|
|
283
|
+
visible=_non_empty(state.clip),
|
|
284
|
+
colour_space=space,
|
|
285
|
+
name=str(op.operands[0]) if op.operands else "",
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
def _image(self, op: content.Operation) -> Paint | None:
|
|
289
|
+
"""A ``Do`` of an image XObject (a form is entered by the content walk, not painted here)."""
|
|
290
|
+
state = self.state
|
|
291
|
+
xobject = content.lookup_xobject(op.resources, op.operands)
|
|
292
|
+
if xobject is not None and str(xobject.get("/Subtype")) == "/Image":
|
|
293
|
+
if xobject.get("/SMask") is not None:
|
|
294
|
+
self.transparency.add("soft mask")
|
|
295
|
+
self.spots.update(spot_names(xobject.get("/ColorSpace"), None))
|
|
296
|
+
bbox = _aabb(op.ctm, [(0, 0), (1, 0), (0, 1), (1, 1)])
|
|
269
297
|
return Paint(
|
|
270
|
-
"
|
|
298
|
+
"image",
|
|
271
299
|
state.fill,
|
|
272
300
|
state.overprint,
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
301
|
+
bbox=bbox,
|
|
302
|
+
visible=self._visible(bbox),
|
|
303
|
+
xobject=xobject,
|
|
304
|
+
colour_space=classify_colour_space(xobject.get("/ColorSpace"), None),
|
|
305
|
+
mask=truthy(xobject.get("/ImageMask")),
|
|
306
|
+
name=str(op.operands[0]),
|
|
307
|
+
matrix=op.ctm,
|
|
308
|
+
mcid=self._mcid(),
|
|
309
|
+
artifact=self._artifact(),
|
|
276
310
|
)
|
|
277
|
-
if name == "INLINE IMAGE":
|
|
278
|
-
return self._inline_image(op)
|
|
279
|
-
if name == "Do":
|
|
280
|
-
xobject = content.lookup_xobject(op.resources, op.operands)
|
|
281
|
-
if xobject is not None and str(xobject.get("/Subtype")) == "/Image":
|
|
282
|
-
if xobject.get("/SMask") is not None:
|
|
283
|
-
self.transparency.add("soft mask")
|
|
284
|
-
bbox = _aabb(op.ctm, [(0, 0), (1, 0), (0, 1), (1, 1)])
|
|
285
|
-
return Paint(
|
|
286
|
-
"image",
|
|
287
|
-
state.fill,
|
|
288
|
-
state.overprint,
|
|
289
|
-
bbox=bbox,
|
|
290
|
-
visible=self._visible(bbox),
|
|
291
|
-
xobject=xobject,
|
|
292
|
-
colour_space=classify_colour_space(xobject.get("/ColorSpace"), None),
|
|
293
|
-
mask=truthy(xobject.get("/ImageMask")),
|
|
294
|
-
name=str(op.operands[0]),
|
|
295
|
-
matrix=op.ctm,
|
|
296
|
-
mcid=self._mcid(),
|
|
297
|
-
artifact=self._artifact(),
|
|
298
|
-
)
|
|
299
311
|
return None
|
|
300
312
|
|
|
301
313
|
def _inline_image(self, op: content.Operation) -> Paint:
|
|
302
314
|
"""A ``BI ... EI`` image. pikepdf expands its abbreviated keys; its colour space may name a resource."""
|
|
303
315
|
image = op.operands[0].obj
|
|
316
|
+
self.spots.update(spot_names(image.get("/ColorSpace"), op.resources))
|
|
304
317
|
bbox = _aabb(op.ctm, [(0, 0), (1, 0), (0, 1), (1, 1)])
|
|
305
318
|
return Paint(
|
|
306
319
|
"inline-image",
|
|
@@ -308,6 +321,7 @@ class Walker:
|
|
|
308
321
|
self.state.overprint,
|
|
309
322
|
bbox=bbox,
|
|
310
323
|
visible=self._visible(bbox),
|
|
324
|
+
xobject=image,
|
|
311
325
|
colour_space=classify_colour_space(image.get("/ColorSpace"), op.resources),
|
|
312
326
|
mask=truthy(image.get("/ImageMask")),
|
|
313
327
|
name="(inline)",
|
|
@@ -496,7 +510,8 @@ class Walker:
|
|
|
496
510
|
self.spots.update(names)
|
|
497
511
|
fill = Fill(OTHER, (1.0,) * len(names), tuple(names)) if names else INITIAL_FILL[family]
|
|
498
512
|
if (base := _pattern_base(space, op.resources)) is not None:
|
|
499
|
-
|
|
513
|
+
self.spots.update(spot_names(base, op.resources))
|
|
514
|
+
fill = Fill(OTHER, pattern=frozenset({classify_colour_space(base, op.resources)})) # for an uncoloured scn
|
|
500
515
|
self._set(**{key: fill})
|
|
501
516
|
|
|
502
517
|
def _components(self, op: content.Operation, key: str = "fill") -> None:
|
|
@@ -515,6 +530,8 @@ class Walker:
|
|
|
515
530
|
if kind == 2: # a shading pattern
|
|
516
531
|
shading = pattern.get("/Shading")
|
|
517
532
|
space = classify_colour_space(shading.get("/ColorSpace"), None) if shading is not None else None
|
|
533
|
+
if shading is not None:
|
|
534
|
+
self.spots.update(spot_names(shading.get("/ColorSpace"), None))
|
|
518
535
|
return frozenset({space}) if space else frozenset()
|
|
519
536
|
if kind != 1:
|
|
520
537
|
return frozenset()
|
|
@@ -524,7 +541,9 @@ class Walker:
|
|
|
524
541
|
if key in self._patterns or len(self._patterns) >= _MAX_PATTERN_DEPTH:
|
|
525
542
|
return frozenset()
|
|
526
543
|
inner = Walker(_patterns=self._patterns | {key})
|
|
527
|
-
|
|
544
|
+
families = frozenset(f for p in inner.walk(pattern) for f in p.families())
|
|
545
|
+
self.spots |= inner.spots
|
|
546
|
+
return families
|
|
528
547
|
|
|
529
548
|
def _graphics_state(self, op: content.Operation) -> None:
|
|
530
549
|
gs = _extgstate(op)
|
|
@@ -43,7 +43,7 @@ def check_image_dpi(pdf: pikepdf.Pdf, min_dpi: float) -> list[Finding]:
|
|
|
43
43
|
for i, page in enumerate(pdf.pages, start=1):
|
|
44
44
|
worst: dict[str, float] = {}
|
|
45
45
|
for op in content.iter_operations(page):
|
|
46
|
-
if op.operator
|
|
46
|
+
if op.operator not in ("Do", "INLINE IMAGE"):
|
|
47
47
|
continue
|
|
48
48
|
measured = _effective_dpi(op)
|
|
49
49
|
if measured is None:
|
|
@@ -66,9 +66,12 @@ def check_image_dpi(pdf: pikepdf.Pdf, min_dpi: float) -> list[Finding]:
|
|
|
66
66
|
|
|
67
67
|
def _effective_dpi(op: content.Operation) -> tuple[str, float] | None:
|
|
68
68
|
"""``(name, dpi)`` for the image this ``Do`` paints, or ``None`` if not measurable."""
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if op.operator == "INLINE IMAGE":
|
|
70
|
+
xobject, name = op.operands[0].obj, "(inline)"
|
|
71
|
+
else:
|
|
72
|
+
xobject, name = content.lookup_xobject(op.resources, op.operands), str(op.operands[0])
|
|
73
|
+
if xobject is None or str(xobject.get("/Subtype")) != "/Image":
|
|
74
|
+
return None
|
|
72
75
|
pixels = _pixel_size(xobject)
|
|
73
76
|
if pixels is None:
|
|
74
77
|
return None
|
|
@@ -78,7 +81,7 @@ def _effective_dpi(op: content.Operation) -> tuple[str, float] | None:
|
|
|
78
81
|
return None
|
|
79
82
|
dpi_x = pixels[0] / (width_pt / PT_PER_IN)
|
|
80
83
|
dpi_y = pixels[1] / (height_pt / PT_PER_IN)
|
|
81
|
-
return (
|
|
84
|
+
return (name, min(dpi_x, dpi_y))
|
|
82
85
|
|
|
83
86
|
|
|
84
87
|
def _pixel_size(xobject: pikepdf.Object) -> tuple[int, int] | None:
|
|
@@ -6,6 +6,8 @@ alternate space is a rendering hint for a spot ink, and treating it as the artwo
|
|
|
6
6
|
on entirely correct print files.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
+
import collections.abc
|
|
10
|
+
|
|
9
11
|
import pikepdf
|
|
10
12
|
|
|
11
13
|
RGB = "rgb"
|
|
@@ -112,9 +114,36 @@ def spot_names(space: object, resources: pikepdf.Object | None, *, depth: int =
|
|
|
112
114
|
return []
|
|
113
115
|
|
|
114
116
|
|
|
117
|
+
def reachable(pdf: pikepdf.Pdf) -> collections.abc.Iterator[pikepdf.Object]:
|
|
118
|
+
"""Every object reachable from the catalog, direct ones included (an ICCBased array is usually inside a dict)."""
|
|
119
|
+
stack: list[pikepdf.Object] = [pdf.Root]
|
|
120
|
+
seen: set[tuple[int, int]] = set()
|
|
121
|
+
while stack:
|
|
122
|
+
obj = stack.pop()
|
|
123
|
+
if not isinstance(obj, pikepdf.Object): # a number, bool or null comes back as a Python value
|
|
124
|
+
continue
|
|
125
|
+
if obj.objgen != (0, 0):
|
|
126
|
+
if obj.objgen in seen:
|
|
127
|
+
continue
|
|
128
|
+
seen.add(obj.objgen)
|
|
129
|
+
yield obj
|
|
130
|
+
if isinstance(obj, (pikepdf.Dictionary, pikepdf.Stream)):
|
|
131
|
+
stack += [value for key, value in obj.items() if key != "/Parent"]
|
|
132
|
+
elif isinstance(obj, pikepdf.Array):
|
|
133
|
+
stack += list(obj)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def output_intents(pdf: pikepdf.Pdf) -> list[pikepdf.Object]:
|
|
137
|
+
"""The catalog's output intents that are dictionaries; a null or stray entry in the array is not one."""
|
|
138
|
+
intents = pdf.Root.get("/OutputIntents")
|
|
139
|
+
if not isinstance(intents, pikepdf.Array):
|
|
140
|
+
return []
|
|
141
|
+
return [intent for intent in intents if isinstance(intent, pikepdf.Dictionary)]
|
|
142
|
+
|
|
143
|
+
|
|
115
144
|
def intent_family(pdf: pikepdf.Pdf) -> str | None:
|
|
116
145
|
"""The colour family of the PDF's first output-intent profile (by its ``/N``), or ``None`` without one."""
|
|
117
|
-
for intent in pdf
|
|
146
|
+
for intent in output_intents(pdf):
|
|
118
147
|
profile = intent.get("/DestOutputProfile")
|
|
119
148
|
if profile is not None and "/N" in profile:
|
|
120
149
|
return _ICC_COMPONENTS.get(int(profile["/N"]))
|
|
@@ -29,14 +29,14 @@ def find(objects: typing.Iterable[pikepdf.Object]) -> list[SpotColour]:
|
|
|
29
29
|
for obj in objects:
|
|
30
30
|
if isinstance(obj, pikepdf.Array) and len(obj) >= 4 and str(obj[0]) in ("/Separation", "/DeviceN"):
|
|
31
31
|
try:
|
|
32
|
-
spot =
|
|
32
|
+
spot = read(obj)
|
|
33
33
|
except IndexError, KeyError, TypeError, ValueError, pikepdf.PdfError:
|
|
34
34
|
continue
|
|
35
35
|
found.setdefault((spot.names, spot.alternate_space), spot)
|
|
36
36
|
return list(found.values())
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def
|
|
39
|
+
def read(space: pikepdf.Array) -> SpotColour:
|
|
40
40
|
separation = str(space[0]) == "/Separation"
|
|
41
41
|
names = (str(space[1]).lstrip("/"),) if separation else tuple(str(n).lstrip("/") for n in space[1])
|
|
42
42
|
alternate = space[2]
|
|
@@ -17,6 +17,7 @@ from PIL import ImageCms
|
|
|
17
17
|
|
|
18
18
|
from ..models import Finding, PageGeometry, Severity, mm_to_pt, pt_to_mm
|
|
19
19
|
from .paint import paint_events
|
|
20
|
+
from .spaces import output_intents
|
|
20
21
|
|
|
21
22
|
# A box that should sit inside another may exceed it by this many points before
|
|
22
23
|
# it is a real error -- guards against rounding in the millipoint box values.
|
|
@@ -165,10 +166,7 @@ def _xmp_bytes(pdf: pikepdf.Pdf) -> bytes:
|
|
|
165
166
|
|
|
166
167
|
|
|
167
168
|
def _has_pdfx_output_intent(pdf: pikepdf.Pdf) -> bool:
|
|
168
|
-
|
|
169
|
-
if intents is None:
|
|
170
|
-
return False
|
|
171
|
-
return any(str(intent.get("/S")) == "/GTS_PDFX" for intent in intents)
|
|
169
|
+
return any(str(intent.get("/S")) == "/GTS_PDFX" for intent in output_intents(pdf))
|
|
172
170
|
|
|
173
171
|
|
|
174
172
|
def check_geometry(pdf: pikepdf.Pdf, geometry: PageGeometry) -> list[Finding]:
|
|
@@ -289,7 +287,7 @@ def _short_sides(page: pikepdf.Page, trim: Rect, zones: list[float]) -> list[dic
|
|
|
289
287
|
fills = [
|
|
290
288
|
(n, p.visible)
|
|
291
289
|
for n, p in enumerate(paint_events(page))
|
|
292
|
-
if p.visible is not None and (p.kind in ("image", "shading") or p.filled)
|
|
290
|
+
if p.visible is not None and (p.kind in ("image", "inline-image", "shading") or p.filled)
|
|
293
291
|
]
|
|
294
292
|
return [_short_on_side(fills, trim, side, zone) for side, zone in enumerate(zones)]
|
|
295
293
|
|
|
@@ -356,7 +354,7 @@ def check_output_condition(pdf: pikepdf.Pdf, expected: str) -> list[Finding]:
|
|
|
356
354
|
Matched against each intent's identifier, condition and info strings and its ICC profile's description, so
|
|
357
355
|
``FOGRA51`` matches an identifier that says so, or a profile called "PSO Coated v3 (FOGRA51)".
|
|
358
356
|
"""
|
|
359
|
-
intents =
|
|
357
|
+
intents = output_intents(pdf)
|
|
360
358
|
if not intents:
|
|
361
359
|
return [
|
|
362
360
|
Finding("output-condition", Severity.ERROR, f"no output intent to compare with the expected {expected!r}")
|
|
@@ -132,6 +132,8 @@ def _check_pdf(path: pathlib.Path, profile: Profile) -> tuple[list[Finding], boo
|
|
|
132
132
|
findings += _text_checks(pdf, profile)
|
|
133
133
|
if profile.colour:
|
|
134
134
|
findings += colour.check_transparency(pdf)
|
|
135
|
+
findings += colour.check_spot_definitions(pdf)
|
|
136
|
+
findings += colour.check_icc_profiles(pdf, profile.colour_mode)
|
|
135
137
|
if profile.colour_mode is ColourMode.RGB:
|
|
136
138
|
findings += colour.check_rgb_only(pdf)
|
|
137
139
|
else:
|
|
@@ -41,7 +41,14 @@ from ._internal import (
|
|
|
41
41
|
)
|
|
42
42
|
from ._internal.paint import Fill, Paint, Walker
|
|
43
43
|
from ._internal.previews import build as build_previews
|
|
44
|
-
from ._internal.spaces import
|
|
44
|
+
from ._internal.spaces import (
|
|
45
|
+
CMYK,
|
|
46
|
+
GRAY,
|
|
47
|
+
RGB,
|
|
48
|
+
classify_colour_space,
|
|
49
|
+
output_intents,
|
|
50
|
+
reachable as _objects,
|
|
51
|
+
)
|
|
45
52
|
from ._internal.vector import INVISIBLE, Group, artwork
|
|
46
53
|
from .inventory import inspect_pdf
|
|
47
54
|
from .layout import Figure, Layout, Line, Table, analyse
|
|
@@ -515,7 +522,7 @@ class _Recovery:
|
|
|
515
522
|
return written[digest]
|
|
516
523
|
|
|
517
524
|
intents = []
|
|
518
|
-
for intent in self.pdf
|
|
525
|
+
for intent in output_intents(self.pdf):
|
|
519
526
|
profile = intent.get("/DestOutputProfile")
|
|
520
527
|
saved = save(profile, "output intent") if profile is not None else None
|
|
521
528
|
intents.append(
|
|
@@ -673,25 +680,6 @@ def _number(value: typing.Any) -> float | None:
|
|
|
673
680
|
return None
|
|
674
681
|
|
|
675
682
|
|
|
676
|
-
def _objects(pdf: pikepdf.Pdf) -> collections.abc.Iterator[pikepdf.Object]:
|
|
677
|
-
"""Every object reachable from the catalog, direct ones included (an ICCBased array is usually inside a dict)."""
|
|
678
|
-
stack: list[pikepdf.Object] = [pdf.Root]
|
|
679
|
-
seen: set[tuple[int, int]] = set()
|
|
680
|
-
while stack:
|
|
681
|
-
obj = stack.pop()
|
|
682
|
-
if not isinstance(obj, pikepdf.Object): # a number, bool or null comes back as a Python value
|
|
683
|
-
continue
|
|
684
|
-
if obj.objgen != (0, 0):
|
|
685
|
-
if obj.objgen in seen:
|
|
686
|
-
continue
|
|
687
|
-
seen.add(obj.objgen)
|
|
688
|
-
yield obj
|
|
689
|
-
if isinstance(obj, (pikepdf.Dictionary, pikepdf.Stream)):
|
|
690
|
-
stack += [value for key, value in obj.items() if key != "/Parent"]
|
|
691
|
-
elif isinstance(obj, pikepdf.Array):
|
|
692
|
-
stack += list(obj)
|
|
693
|
-
|
|
694
|
-
|
|
695
683
|
def _metadata(pdf: pikepdf.Pdf, out_dir: pathlib.Path, failures: list[str]) -> dict[str, typing.Any]:
|
|
696
684
|
"""The document info, and the XMP packet both saved as ``xmp.xml`` and decoded (long values, such as embedded
|
|
697
685
|
thumbnails, are left in the file and named in the data)."""
|
|
@@ -14,7 +14,6 @@ import pikepdf
|
|
|
14
14
|
|
|
15
15
|
from ._internal import contrast, fonts, structure
|
|
16
16
|
from ._internal.paint import Paint, Walker
|
|
17
|
-
from ._internal.spaces import classify_colour_space
|
|
18
17
|
from .models import PT_PER_IN, pt_to_mm
|
|
19
18
|
|
|
20
19
|
|
|
@@ -96,7 +95,12 @@ def inspect_pdf(
|
|
|
96
95
|
fonts=_font_facts(walks),
|
|
97
96
|
text_colours=_text_colours(walks),
|
|
98
97
|
spot_inks=sorted({name for _, _, spots in walks for name in spots}),
|
|
99
|
-
images=[
|
|
98
|
+
images=[
|
|
99
|
+
_image_fact(number, e)
|
|
100
|
+
for number, events, _ in walks
|
|
101
|
+
for e in events
|
|
102
|
+
if e.kind in ("image", "inline-image")
|
|
103
|
+
],
|
|
100
104
|
contrast=contrast_facts,
|
|
101
105
|
contrast_error=error,
|
|
102
106
|
)
|
|
@@ -186,7 +190,7 @@ def _image_fact(page: int, event: Paint) -> ImageFact:
|
|
|
186
190
|
return ImageFact(
|
|
187
191
|
page=page,
|
|
188
192
|
name=event.name,
|
|
189
|
-
colour_space=
|
|
193
|
+
colour_space=event.colour_space or "other",
|
|
190
194
|
pixels=(width, height),
|
|
191
195
|
dpi=dpi,
|
|
192
196
|
)
|
|
@@ -19,6 +19,8 @@ import pikepdf
|
|
|
19
19
|
from PIL import ImageCms
|
|
20
20
|
|
|
21
21
|
OUT = pathlib.Path(__file__).parent / "pdfs"
|
|
22
|
+
# The LaTeX samples (samples/NAME.tex, built by samples/build.py) put their PDFs in this same directory.
|
|
23
|
+
SAMPLES = {p.stem for p in (pathlib.Path(__file__).parent / "samples").glob("*.tex")}
|
|
22
24
|
|
|
23
25
|
MM = 72.0 / 25.4
|
|
24
26
|
TRIM_W, TRIM_H, BLEED = 105.0 * MM, 148.0 * MM, 3.0 * MM
|
|
@@ -387,7 +389,7 @@ def main() -> int:
|
|
|
387
389
|
for n, data in built.items()
|
|
388
390
|
if not (OUT / f"{n}.pdf").is_file() or (OUT / f"{n}.pdf").read_bytes() != data
|
|
389
391
|
]
|
|
390
|
-
stale += [p.stem for p in OUT.glob("*.pdf") if p.stem not in built]
|
|
392
|
+
stale += [p.stem for p in OUT.glob("*.pdf") if p.stem not in built and p.stem not in SAMPLES]
|
|
391
393
|
if stale:
|
|
392
394
|
print(f"stale fixtures: {', '.join(sorted(stale))}; run build_pdfs.py", file=sys.stderr)
|
|
393
395
|
return 1
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|