Pillow: Why does Pillow invert the color of a CMYK image when converting to PDF?

Created on 13 Aug 2020  路  4Comments  路  Source: python-pillow/Pillow

What did you do?

Using PIL to open a JPEG(CMYK) and then save it as PDF

What did you expect to happen?

A PDF with CMYK image.

What actually happened?

A PDF with CMYK image but the colors are inverted.

What are your OS, Python and Pillow versions?

  • OS: Mac OS V 10.15.6
  • Python: 3.7.6
  • Pillow: 6.2.2
from PIL import Image, ImageOps

image = Image.open('door.jpg')
image.save(
  'output.pdf',
  resolution=180.0,
  quality=100
)

input and output image
i7PYq

Note: I tried converting the image to RGB prior to saving it as PDF and it works as intended. But since the PDF is meant for printing purpose, I need the image to be in CMYK.

Since I did not get an answer on Stackoverflow and it does seem like either a limitation in Pillow or perhaps not documented, i'm creating a ticket here.

Bug

All 4 comments

For reference, the Stack Overflow question:

Hi. I've created PR #4866 to fix this bug.

You haven't provided us your original CMYK image, so if you could test it and confirm that it solves your situation, that would be good.

Hi, thanks for the quick fix, I confirm that this PR fixes the issue I encountered.

@vinodMS Thank you for the report, and for testing the PR!

@radarhere Thank you for the PR, merged!

Was this page helpful?
0 / 5 - 0 ratings