You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Profile-based Color Management for Preview and PDF export #3143
feature requestNew feature or requesthelp wantedExtra attention is neededpdfRelated to PDF export or PDF embedding.pngRelated to PNG export.visualizeRelated to the visualize category, which is about drawing and illustrating
allow to specify an output ICC color profile (e.g. command line option --icc-profile ).
convert the colors to the specified output profile when writing the pdf. If none is specified default to the sRGB profile currently used.
use a "proofing" transform (see details) to RGB so we get a better preview of CMYK colors.
include a few commonly used ICC profiles to improve usability. The most commonly used color profile for offset print ist ISOcoatedv2.
2. Details
One of the most popular color management C libraries is Little-CMS, which is used by Scribus, Imagemagick, GIMP, Inkscape and many more. It is open source (MIT License).
For improving the preview of documents with CMYK-colors, it offers a function cmsCreateProofingTransform that allows a transformation to RGB that tries to get the colors to look on the screen as it would when printed with the destination profile. (see the docs,p.25)
Use Case
CMYK colors are supported in typst. However most printers require an embedded CMYK color profile in the pdf file.
Additionally, improving the preview of cmyk colors in the Web App so it is consistent with common pdf viewers (that use proper color management) would be helpful.
To illustrate this issue: create a CMYK color that mixes Cyan and Magenta, e.g. cmyk(80%,80%,0,0). Observe how it is blue in the webapp but violet in the downloaded pdf.
Reacted by Tiemen Schuijbroek, Linus Weber, laikq, Florian Obernberger, mrwunderbar666, Я́лла Нкарда́з д͏е Туде́рий, Jonah Bauer, Belim, Alexander Schories and JDuffe
allow to specify an output ICC color profile (e.g. command line option --icc-profile )
I think maybe it would even be better to allow specifying icc profiles within a Typst document via some setting, this way it would be reproducible across different platforms.
One of the most popular color management C libraries is Little-CMS, which is used by Scribus, Imagemagick, GIMP, Inkscape and many more. It is open source (MIT License).
Afaik we can only use Rust dependencies, because there are linking issues between C and Rust when compiling to WASM.
I think maybe it would even be better to allow specifying icc profiles within a Typst document via some setting, this way it would be reproducible across different platforms.
Yes that would be better.
Afaik we can only use Rust dependencies, because there are linking issues between C and Rust when compiling to WASM.
The qcms repo unfortunately does not have a license and has its issue tracker closed. I dmmed a maintainer on Discord about this but received no answer. Does anyone know a collaborator there? Otherwise, we could fork the project (however not without a license)
yes the repo is not the best maintained.
However there is a license in the comments of the source files, here for example
// qcms
// Copyright (C) 2009 Mozilla Foundation
// Copyright (C) 1998-2007 Marti Maria
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software,
...
The Marti Maria mentioned here is the original author of LIttleCMS. So while this repo does not make it perfectly clear i assume that the c to rust translation they did is from the original source code of lcms.
If this goes nowhere however, the next best starting point would be the charmingly old fashioned website of the ICC
Under resources, there are reference implementations for working with ICC profiles.
I think maybe it would even be better to allow specifying icc profiles within a Typst document via some setting, this way it would be reproducible across different platforms.
Yes that would be better.
Afaik we can only use Rust dependencies, because there are linking issues between C and Rust when compiling to WASM.
I think maybe it would even be better to allow specifying icc profiles within a Typst document via some setting, this way it would be reproducible across different platforms.
Yes that would be better.
Afaik we can only use Rust dependencies, because there are linking issues between C and Rust when compiling to WASM.
yes but these are just the three header files in the root directory. As far as I understand this is only there so the library can be called from C code. If you look in the rust code all functionality for converting ICC profiles is in rust.
Some rust functions are declared extern "C" so they are probably meant to be used by some parts of Mozillas gfx library that is still in C.
So whats missing is a function that reads the CMYK=>PCS (CIEXYZ) translation table from the icc file. right?
What ICC spec should this be based on? It looks like PDF/X still recommends ICCv2 and not the newest major version 4.
For our intents and purposes ICCv2 would be fine, but best to discuss this on the #gfx:mozilla.org as well! Maybe they aim for compatibility with both formats.
It's worth noting that the qcms's CMYK support currently only supports going from CMYK to RGB. If you need to go in the other direction support will need to be added.
Jeff, thank you so much for chiming in here, a better rendition of CMYK colors on screen already solves half our problems and I"ll look into the to-CMYK transform but the ICC spec is not that easy to understand. I'll look into it as soon as I find the time.
feature requestNew feature or requesthelp wantedExtra attention is neededpdfRelated to PDF export or PDF embedding.pngRelated to PNG export.visualizeRelated to the visualize category, which is about drawing and illustrating
Activity
LaurenzV commentedon Jan 6, 2024
I think maybe it would even be better to allow specifying icc profiles within a Typst document via some setting, this way it would be reproducible across different platforms.
Afaik we can only use Rust dependencies, because there are linking issues between C and Rust when compiling to WASM.
tilman-schieber commentedon Jan 6, 2024
Yes that would be better.
I just found out that Firefox used to use Little-CMS but they redid it in Rust (!) https://github.com/FirefoxGraphics/qcms/
reknih commentedon Jan 7, 2024
The qcms repo unfortunately does not have a license and has its issue tracker closed. I dmmed a maintainer on Discord about this but received no answer. Does anyone know a collaborator there? Otherwise, we could fork the project (however not without a license)
tilman-schieber commentedon Jan 7, 2024
yes the repo is not the best maintained.
However there is a license in the comments of the source files, here for example
The Marti Maria mentioned here is the original author of LIttleCMS. So while this repo does not make it perfectly clear i assume that the c to rust translation they did is from the original source code of lcms.
If this goes nowhere however, the next best starting point would be the charmingly old fashioned website of the ICC
Under resources, there are reference implementations for working with ICC profiles.
Enivex commentedon Jan 7, 2024
It still says 2.8% c++ and 2.6% c
tilman-schieber commentedon Jan 7, 2024
yes but these are just the three header files in the root directory. As far as I understand this is only there so the library can be called from C code. If you look in the rust code all functionality for converting ICC profiles is in rust.
Some rust functions are declared
extern "C"so they are probably meant to be used by some parts of Mozillas gfx library that is still in C.reknih commentedon Jan 9, 2024
I have successfully reached out to the Firefox Graphics team on Matrix (#gfx:mozilla.org). qcms will bump on Cargo and add a license and
CONTRIBUTING.mdfile (https://phabricator.services.mozilla.com/D197955). Prior to our adoption, CMYK support would need to be added (see https://bugzilla.mozilla.org/show_bug.cgi?id=1474560). Is anyone interested in taking this up? If not, we can do it, but it will take some time.tilman-schieber commentedon Jan 9, 2024
So whats missing is a function that reads the CMYK=>PCS (CIEXYZ) translation table from the icc file. right?
What ICC spec should this be based on? It looks like PDF/X still recommends ICCv2 and not the newest major version 4.
reknih commentedon Jan 9, 2024
For our intents and purposes ICCv2 would be fine, but best to discuss this on the #gfx:mozilla.org as well! Maybe they aim for compatibility with both formats.
tilman-schieber commentedon Jan 9, 2024
Lo and behold:
qcms added CMYK support in the commit FirefoxGraphics/qcms@7f4e64c
see also the comments of qcms's author: FirefoxGraphics/qcms#35
the cmyk update will be published as a crate soon.
jrmuizel commentedon Jan 9, 2024
It's worth noting that the qcms's CMYK support currently only supports going from CMYK to RGB. If you need to go in the other direction support will need to be added.
jrmuizel commentedon Jan 9, 2024
v0.3.0 has now been published. Let me know if there's anything else that you need.
tilman-schieber commentedon Jan 9, 2024
Jeff, thank you so much for chiming in here, a better rendition of CMYK colors on screen already solves half our problems and I"ll look into the to-CMYK transform but the ICC spec is not that easy to understand. I'll look into it as soon as I find the time.
terefang commentedon Sep 6, 2025
hello, for the late call.
will this also allow spot color support in some way ?