New in QGIS 3.40 : CMYK Support

By Wednesday October 2nd, 2024NewsFR

Credits : Bru-nO (Pixabay Content License)

Thanks to funding from the Bordeaux Metropolis, I had the chance to work on CMYK (Cyan Magenta Yellow blacK) support in QGIS. The metropolis’ goal is to remove the last barrier preventing their complete migration from ArcGIS to QGIS.

The developments are now complete and will be available in QGIS version 3.40, scheduled for release in October 2024, before becoming the next LTR in February 2025. It should be noted, however, that CMYK support will only be complete in QGIS versions built with Qt 6 (still unofficial version) for reasons explained in the article. On Windows, this version can currently only be installed using OSGeo4W (qgis-qt6-dev version).

What is CMYK?

You probably know RGB, which allows you to code a color on screen by choosing the amount of red, green and blue in that color. You may also use TSL or TSV.

RVB – Credits : Daniel Roberts (Pixabay Content License)

These 3 color references allow a color to be coded for a screen, while CMYK targets printers by allowing to set the exact quantity of ink that will be released during printing (hence the 4 CMYK components, one per ink cartridge).

 

CMYK ( here from left to right KCMY ) – Credits : Magnascan (Pixabay Content License)

The characteristics of CMYK differ greatly from RGB, it’s considered a subtractive colorimetric mode, because the ink absorbs light unlike RGB which is said to be additive, the more red, green, blue you have the closer you are to full light, white.

The intrinsically different nature of these 2 color spaces means that it is strongly advised not to convert from one to the other. The best is to choose a color in a space (CMYK for printing, RGB for rendering on screen) and stick to it.

Worse, printing the same color is different depending on the printer, ink, paper… The choice of a CMYK color has to be done in a color space, represented by a ICC profile file, provided by your printer. It is a bit like a color chart used when choosing paint.

 

Now you can argue about the REALLY good color of a road line – Credits : Yanis Ladjouzi (Pixabay Content License)

Developments in QGIS… and Qt

It is now possible in QGIS to:

  • Enter colors in CMYK format, and in floating precision;
  • Define your preferred color mode (RGB or CMYK) and your color space;
  • Generate a file in PDF/X-4 format (ready for printing) embedding a color space and using CMYK colors;
  • Allow the expression engine to manipulate CMYK colors without converting them to RGB;
  • Manage CMYK color ramps;
  • Lots of other small improvements and corrections about color management.

 

Selecting colors in QGIS in CMYK

The beautiful story of Open source

I took great pleasure in participating in this development because it is the result of the collaboration of many players in free software.

During a first phase of study concerning the support of CMYK in QGIS, we quickly identified that Qt, the framework used by QGIS for rendering maps, has limitations. It converts all colors to RGB when rendering maps in PDF format and its support for CMYK color spaces is incomplete.

It is therefore necessary to make it evolve. We therefore turn to our preferred partner when it comes to Qt, KDAB, and more precisely Giuseppe D’Angelo who then carries out the necessary developments.

Regarding new features, these are only available in Qt 6 (Qt 5 is end of life). This is why CMYK support is incomplete in official versions of QGIS still based on Qt 5.

QGIS.org, the association that oversees the QGIS project, decided to fund the developments on Qt. Oslandia, on the other hand would have to manage these developments and then to carry out the integration in QGIS. This integration as well as the related new features was funded by the Bordeaux metropolis.

My developments were then reviewed by other QGIS contributors. (If you want to know more about the QGIS contribution process, you can read a previous blog post about software quality in QGIS)

Finally, I wanted to give a special thanks to Jehan, developer on the GIMP project. His availability and thoroughness in our mail exchanges greatly helped me understand the technical and functional issues of CMYK, and most certainly contributed to the quality of the result.

Next

QGIS 3.40 will therefore be able to generate a PDF/X-4 file using CMYK colors. Qt, for its part, improves CMYK support, PDF writing, and color space management.

Thanks again to the Bordeaux metropolis and QGIS.org for funding these developments, and all the people involved in their realization.

We would be delighted to have feedback from users on your use cases related to color management in QGIS. Do not hesitate to write to us or comment on our posts to tell us how you use these features.

These foundations in the management of color spaces in QGIS open the door to future improvements. If you are interested in this topic and would like to contribute, please contact us at infos+qgis@oslandia.com and check out our QGIS support offer.