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

Support color profiles #844

Open
LukasKlement opened this issue Apr 1, 2019 · 14 comments
Open

Support color profiles #844

LukasKlement opened this issue Apr 1, 2019 · 14 comments
Labels
feature New feature that should be supported

Comments

@LukasKlement
Copy link

Is there a way to change the colour profile to CMYK? Whilst it's easy to use PIL for jpgs, I haven't found a way to do it for entire PDFs.

There will be cmyk() support in CSS4, but that's still some time to go: https://www.w3.org/TR/css-color-4/#cmyk-colors

@liZe
Copy link
Member

liZe commented Apr 1, 2019

Is there a way to change the colour profile to CMYK? Whilst it's easy to use PIL for jpgs, I haven't found a way to do it for entire PDFs.

Cairo (the library used in WeasyPrint to generate PDF and PNG files) doesn't support CMYK. Here's a sad post about it, it's old but still relevant.

@liZe liZe added the feature New feature that should be supported label Apr 1, 2019
@liZe liZe changed the title Convert PDF to CMYK colours Support color profiles Apr 1, 2019
@LukasKlement
Copy link
Author

LukasKlement commented Apr 1, 2019

Perhaps we could tackle this by converting the colour space after generating PDFs? I've seen an approach on this here: https://github.com/johndoe31415/pdfminify/blob/master/llpdf/filters/PDFAFilter.py

This might help us making some progress on this ticket as well: #630

@liZe
Copy link
Member

liZe commented Apr 1, 2019

Perhaps we could tackle this by converting the colour space after generating PDFs?

Yes, we can do that, but only if we use colors that can have a RGB representation in a bijective way (as we'll have to use cairo at one moment, and cairo can only store RGB colors).

I've seen an approach on this here
This might help us making some progress on this ticket as well: #630

pdfminify? What an interesting project, wow. You're right, it may be really helpful.

@liZe
Copy link
Member

liZe commented Apr 4, 2020

Related to #1091.

@dominikhuetter
Copy link

Is there any update on this issue?

@liZe
Copy link
Member

liZe commented Feb 28, 2022

Is there any update on this issue?

Now that we use our own PDF generator, it could be possible to support more features about color profiles. That’s not planned for the next milestones, but it may be in the future.

@hejsan
Copy link
Contributor

hejsan commented Mar 29, 2022

Could you point to the relevant code sections where CMYK support would fit?

@liZe
Copy link
Member

liZe commented Mar 29, 2022

Could you point to the relevant code sections where CMYK support would fit?

That’s a very good question. I don’t know the PDF specification well enough to know how to generate a PDF with color profiles, so it’s pretty hard to tell where the relevant code is…

@grewn0uille
Copy link
Member

grewn0uille commented Sep 12, 2022

Hello!

As it’s soon our 2-year anniversary as CourtBouillon, we opened a short survey to know more about your expectations.
Don’t hesitate to support this feature and give it a boost 🚀!

The survey will be opened until October 10th.

Update: the survey is now closed. You can find the results here.

@TellersFella
Copy link

Hey, I just looked at the survey results and color profiles seem relevant, but not at the absolute top of the list. So my question is, is there anything planned regarding this?

@liZe
Copy link
Member

liZe commented Nov 15, 2022

Hi @TellersFella!

As you have seen with the survey results, color profiles are not our top priority. However, there has been two interesting steps recently:

When Color 4 is fully implemented, we will be able to work on the next step: support ICC-based colors in WeasyPrint for CSS (and for images…). With that, we should be able to handle everything that can be done with color profiles in PDF files.

Note that supporting naive CMYK colors directly in CSS will require to support CSS Color Module Level 5.

@davidmarogy
Copy link

Hello @liZe,

i just wanted to ask if there is any new updates regarding implementation of ICC-based colors or any CMYK conversion in Weasyprint?

Best regards,
David

@liZe
Copy link
Member

liZe commented Mar 28, 2023

i just wanted to ask if there is any new updates regarding implementation of ICC-based colors or any CMYK conversion in Weasyprint?

Yes, some work has been done, but we’re not close to a proper CMYK support in WeasyPrint yet.

What we’ve been working on is the support of CSS color level 4 in tinycss2. This feature will enable the possibility to define non-RGB colors using CSS. The work is not merged yet (mainly because we’ve got a lot of work on other parts of WeasyPrint), but hopefully most of the code is already written. Tests and ideas to solve the latest missing features are welcome!

The next step is to include this support in WeasyPrint. It means that we’ll have to manipulate abstract colors instead of RGB colors everywhere, and that we’ll have to write the correct PDF data according to the space of the color. Images are another topic we have to take care of. That’s not done at all.

And we didn’t even talk of ICC and CMYK yet!

These features are possible with CSS color level 5, thanks to @color-profile. We need to add the support of level 4 in tinycss2, and then in WeasyPrint. It should be easier than adding level 4 support though, because we’ll already have done the work to support different color spaces.

@grewn0uille
Copy link
Member

Hello!

As you may know, two weeks ago was CourtBouillon 3-year anniversary 🎉.

For this occasion, we prepared a short survey to have your opinion on this year’s features and to know what you’d like to see in the future!
Don’t hesitate to give a boost to this feature ✨️

The survey is opened until November 19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

7 participants