Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMYK JPEGs appearing inverted in PDF output #2179

Merged
merged 1 commit into from
Jun 8, 2024
Merged

CMYK JPEGs appearing inverted in PDF output #2179

merged 1 commit into from
Jun 8, 2024

Conversation

endaxi
Copy link

@endaxi endaxi commented Jun 7, 2024

Addresses issue #1128

According to libjpeg "it appears that Adobe Photoshop writes inverted data in CMYK JPEG files"

An Adobe JPEG can be identified by the presence of the APP14 segment.

The code now checks for the APP14 segment in RasterImage and adds a Decode Array to the XObject when rendering the CMYK JPEG. The value of the Decode Array is the inverse of the default value for DeviceCMYK according to the PDF spec. This has the effect of inverting the inverted image back to normal.

Addresses issue [Kozea#1128](Kozea#1128)

According to
[libjpeg](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/3c17063ef1ab43f5877f19d670dc39497c5cd036/libjpeg.txt#L1569-L1582)
"it appears that Adobe Photoshop writes inverted data in CMYK JPEG
files"

An Adobe JPEG can be identified by the presence of the
[APP14](https://exiftool.org/TagNames/JPEG.html#Adobe)
segment.

The code now checks for the `APP14` segment in `RasterImage` and adds a
Decode Array to the XObject when rendering the CMYK JPEG. The value of
the Decode Array is the inverse of the default value for DeviceCMYK
according to the PDF spec. This has the effect of inverting the inverted
image back to normal.
@liZe liZe added this to the 63.0 milestone Jun 8, 2024
@liZe liZe linked an issue Jun 8, 2024 that may be closed by this pull request
@liZe liZe merged commit 4ce48a4 into Kozea:main Jun 8, 2024
6 checks passed
@liZe
Copy link
Member

liZe commented Jun 8, 2024

Thank you! ❤️

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.

Image prints with black background
3 participants