Repository navigation
feat(pdf): CMYK pictures stay CMYK in PDFs - #1059
Merged
Merged
Conversation
A CMYK PSD, TIFF or JPEG β PDF came out RGB (or failed, for JPEG): PDFsharp's image import takes grey and RGB only. Print work needs its CMYK (#1027), so CmykPictures writes the image XObject itself: DeviceCMYK, or the picture's own profile as an ICCBased colour space; a JPEG source as JPEG data (ImageMagick's CMYK JPEGs are inverted with Adobe's APP14 marker, which a Decode array undoes), anything else as its samples, losslessly; transparency as a soft mask. Grey and RGB pictures go in through PDFsharp as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1027. A print user's CMYK PSD β PDF came out RGB, and a CMYK JPEG β PDF failed (fixed in #1057 by making it RGB). Print work needs its CMYK kept.
PDFsharp's image import takes grey and RGB only, so
Pdf/CmykPictures.cswrites the image XObject itself for CMYK pictures:ICCBased(N=4, alternate DeviceCMYK), orDeviceCMYKwithout one. A PSD with Japan Color 2001 Coated keeps it.DCTDecode, the preset's quality, at least 85 as before). ImageMagick writes CMYK JPEGs inverted with Adobe's APP14 marker, as Photoshop does, so aDecode [1 0 β¦]array undoes it. Anything else (PSD, TIFF, β¦) as its CMYK samples, losslessly (FlateDecode).SMask).cm β¦ Doin the page's content.Grey and RGB pictures still go through PDFsharp unchanged.
Tested
New
CmykPdfTests, each read back with PDFsharp and drawn back with PDFium:ICCBased N=4(DCT for JPG, Flate for the others), and the rendered page shows orange and navy where they are;DeviceCMYK, colours right;DeviceRGB;Engines PDF/image tests 249 pass (26 skipped for engines not installed here);
dotnet format --verify-no-changesclean.The other half of #1027 (a CMYK AI / PDF β JPG keeps CMYK) comes in its own PR.
π€ Generated with Claude Code