Using PIL to open a JPEG(CMYK) and then save it as PDF
A PDF with CMYK image.
A PDF with CMYK image but the colors are inverted.
from PIL import Image, ImageOps
image = Image.open('door.jpg')
image.save(
'output.pdf',
resolution=180.0,
quality=100
)
input and output image

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.
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!