LWN.net Logo

Integrated color management with colord

September 28, 2011

This article was contributed by Nathan Willis

Desktop Linux users used to be easily divided into two camps when it came to color management: there were the graphics geeks — who painstakingly profiled their scanners, printers, and displays and manually set up color management in each of their creative applications — and there was everyone else, who saw color management as an esoteric hobby with no practical value. The color geeks are quietly taking over, however, thanks to recent work that automates color management at the system and session level.

The root of the color management problem is that no two devices have exactly the same color reproduction characteristics: monitors and printers vary wildly in the tonal range and gamut that they can reproduce; similarly cameras and scanners vary wildly in what they can pick up. If you spend all week staring at a single display device it is easy to forget this, but anyone who has set their netbook on the desk beside a desktop LCD display recognizes immediately how different they can be. As a practical matter, when a user makes a printout and finds it too dark, or orders a piece of clothing online and is surprised at its color when it arrives, lack of color management is the problem.

But color management is essentially a solved problem that has yet to be implemented system-wide on Linux. Every display or input device can be profiled — that is, its color characteristics measured and saved in a standardized format like an ICC color profile. With profiles in hand, applications need only to perform a transformation on RGB data to map it from one profile (say, a camera's) to another (a display's). Most of the time, a mapping with a perceptual rendering intent is used, which means the final image will appear the same to the human eye on the display as it did through the camera viewfinder.

The old way

Several free software packages exist for applications to perform these transformations. By far the most popular is LittleCMS, an MIT-licensed library used by GIMP, Krita, ImageMagick, Inkscape, Scribus, and many other graphics applications. Another well-known alternative is Argyll, which is licensed under the AGPL. Argyll consists of a collection of command-line tools, however, rather than a shared library designed for use by application programs.

LittleCMS support simply gives each application the ability to perform profile-to-profile transformations. Users are still required to open the preferences dialogs in each application and specify the .icc file for each profile used in their hardware setup. As a result, "color management" came to be a feature that could be enabled or disabled on a per-application basis, since only a small percentage of users cared enough to have profiles for their displays and printers. A far better approach would be for the system to keep track of the relevant profiles (since displays, scanners, and printers tend to stay put for long periods of time), and have applications automatically retrieve them as needed — no user intervention required. That is the approach taken by both Windows and Mac OS X.

The technicolor dawn

This is where Richard Hughes's colord and Gnome Color Manager (GCM) come into play. Colord is a framework for automating the storage and retrieval of color profiles. It includes a system daemon that maintains an SQLite database to track which profiles map to which devices; it also provides a D-Bus interface for other programs to query (or in the case of GCM, add and change) profiles.

It can retrieve scanner and printer device IDs through Udev and present a simple interface with which users can select their preferred profile for each device. Multiple profiles per device are supported, to allow separate profiles for different paper stocks, ink options, flatbed and transparency adapters, and other parameters. An application can ask for the profile for a specific device using dot-separated qualifiers, such as RGB.Glossy.600dpi. If colord does not have a stored profile for the requested qualifiers, it can fall back one parameter at a time to find the best match, e.g., to RGB.Glossy.* or RGB.*.600dpi, and eventually back to RGB.*.* and the default * for a device ID.

The other half of the framework is GCM, which is a session-level process implemented as a GNOME settings daemon plug-in. GCM talks to the X.org session to retrieve the display device information through XRandR and, where possible, to set display settings such as video card gamma tables (VCGTs). The session-level process can also read ICC profile files stored in the user's home directory (as opposed to the system-wide ICC profile directories /var/share/color and /var/lib/color, which are watched by the colord daemon).

Hughes said in a recent talk that the system/session split, though it sounds confusing at first, is required for several reasons. First, the system daemon needs to talk to other system-level processes such as CUPS (for printers) and SANE (for scanners), and needs to work even when there is no active user session (consider shared printers, printers that print directly from memory cards, and GDM login screens, for example). But the session-level process also needs to be separated from privileged operations for other reasons. SELinux will not allow a system daemon to load files (in this case, ICC profiles) from a user's home directory because of security concerns, and colord would not even be able to read them if the home directory is encrypted. The separation also makes it possible for KDE, LXDE, or other environments to write their own colord-compatible session management code independent of GCM.

The application's viewpoint

The framework provided by colord and GCM is very high-level; applications must still do the color transformations using LittleCMS or another library. But by relying on colord to provide the correct profile information for a particular hardware device, there is less for the application developer to worry about.

GCM provides an interface for the user to manage his or her profiles, which alleviates the problem of manually setting the same preferences in every application. But applications do need to be updated to work with colord. At the moment, the list of colord-compatible programs is short: Hughes told Alexandre Prokoudine at Libre Graphics World that it includes CUPS, Foomatic, Simple Scan, and Compiz-CMS. The GTK+ toolkit is also compatible he said, and KDE support is on the way.

General-purpose GTK+ or KDE applications can decide to entrust colord with their entire color management workflow, but creative applications may still want to provide additional options. For example, users may want to simulate an output device with a different profile to "soft proof" before printing or rendering images. Colord can still help, because it can maintain profiles for "virtual devices" in addition to the local hardware, but of course presenting that functionality to the user requires pulling back the curtain away from the "it just works" approach favored by simple applications.

Perhaps understandably, support for colord among the already-color-aware Linux creative suite appears to be growing slowly. Krita has integration plans, but it may be a while before the other applications that already implement color management adopt colord, on the grounds that the users who already care have also already configured their software.

On the other hand, Hughes has been busy submitting patches to other projects to enable colord support. He added the colord support now found in CUPS' gstoraster filter (which converts PostScript and PDF content to raster data) and foomatic (which can directly generate printer-language files) and has reportedly been patching other tools as well. Colord debuted in 2010, and was available in GNOME 3.0, but is now a hard dependency for the imminently-due GNOME 3.2, so for the first time, application developers can count on its availability.

Where profiles come from

As a practical matter, the big lingering question for end users is where the all-important device profiles come from. After all, it makes no difference how easily the applications can retrieve the default profile for a display or printer if there is no profile available. Hughes has designed colord to support profiles from a variety of sources, and always takes the "the user is right" approach: a manually-selected profile is assumed to be better than a generic one.

The best possible profiles are those that are created with proper measuring device: a tristimulus colorimeter for displays, a high-quality target for scanners or digital cameras, or a spectrophotometer for a printer. But all of these methods involve some outlay of cash. The price of colorimeters has fallen sharply in recent years, but even the cheapest devices run close to US $100, which can sound excessive for a hardware device only used on isolated occasions. There are non-profit producers of quality IT 8.7 targets, such as Wolf Faust, but they are still not free. Spectrophotometers, which measure reflected light, remain expensive, although there are paid services to which users can mail a test printout and get a high-quality ICC profile in return. But the one-time cost of buying such a profile rises when you consider the need to have each ink and paper combination measured separately.

Still, GCM does support creating a display profile with a USB colorimeter, importing camera or scanner images of calibration targets for scanner or camera profiles, and scanning printouts to generate printer profiles. GCM uses the low-level profiling tools from Argyll for much of this process, but Hughes has also been adding native drivers for common colorimeters like the Pantone Huey.

The next rung down on the quality ladder is manufacturer-provided profiles. These vary depending on device type and quality control. An expensive film scanner might ship with an accurate profile on the accompanying CD, while an inexpensive laptop display is completely hit or miss. As Hughes explained,

I have a T61 laptop with a matte 15" screen, but as any T61 owner [who's smashed their screen] knows, the T61 can have about half a dozen different panel types from factories in a few different countries. So trying to come up with the ultimate T61 laptop profile is going to be really tricky.

Even where manufacturer-provided profiles exist, however, Linux distributions generally do not have the rights to ship them, so they are inaccessible to an "it just works" framework.

As an alternative, Hughes said, GCM can probe XRandR devices for Extended display identification data (EDID), and auto-generate a basic display profile based on it.

If (and this is a big "if") the vendor puts semi-sane data into the EDID then we can get some chromaticity and whitepoint co-ordinates which allows us to generate a profile that's certainly better than the default.

Here again, Hughes warned that the quality of the device in question correlates to the quality of the EDID data one should expect. Manufacturers who regularly swap in LCD panels from Korea, China, and Taiwan without indicating a difference in the model number are likely to burn in generic EDID data that covers the average characteristics of the product line.

Unfortunately, how useful the provided EDID data is can also depend on extraneous factors like the video driver. For example, the NVIDIA binary drivers only support XRandR 1.2, which in turn does not include support for sending separate VCGTs to multiple monitors. Thus regardless of the quality of the data, at least one display will be forced to use gamma tables that are only accurate for a different monitor. It is also possible to run into older monitors that do not provide EDID information at all, or to have KVM switches or splitters lose it en route to the video card.

Kai-Uwe Behrmann of the Oyranos project, a competing color management framework, recently undertook an effort to build an open, user-contributed database of device profiles. Called taxi, the system was developed in the 2011 Google Summer of Code by student Sebastian Oliva. There is a web front-end running at icc.opensuse.org, which returns both raw .icc files and JSON-formatted metadata about the source device. It is an interesting approach, though one with its own set of problems. Display characteristics change over time, for example, as the backlight ages, and there is no way to verify the conditions under which another person's profile was created.

In the final analysis there is no automated substitute for a good profile created with quality test materials; a fallback profile will always be better than nothing, but unpredictable. Perhaps the best thing the community at large can do if it wishes to spread good, non-generic profiling is to make sure that the distributions and desktop environments pack a colorimeter and IT 8.7 target into the "booth box" when heading to community Linux shows. It certainly would not hurt.

The future

The colord daemon and GCM session manager provide the framework on which future applications can build end-to-end, "it just works" color management for the Linux desktop environment. That future is a big step up from the recent past, where each color-aware application needed to pester the user individually for a collection of profile settings, but it is still not color nirvana. For that one needs to look ahead to full-screen color management.

Hughes outlined the situation in his interview at Libre Graphics World. A full-screen color managed system would need a color-aware compositing manager, but would also allow applications to mark specific regions of the screen to "opt out" from the transformation — UI widgets are assumed to have sRGB pixels, for example, but a photograph would have a camera profile instead. But by pushing the transformation into the compositor, it becomes possible to offload the calculations to the GPU, potentially speeding up workflow dramatically.

The compiz-cms plug-in is an attempt to do this, although an incomplete one: because the applications are not able to mark specific regions with different transformation needs, the plug-in assumes all images are sRGB. For Compiz users, however, it is an intriguing glimpse at the possibilities.

Behrmann has developed a draft specification for communicating color regions, formerly called net-color but recently renamed X Color Management (currently in the draft stage for version 0.3). Hughes has concerns about the specification for use with colord, including its network transparency and its ease of implementation for application developers, but so far there is not a competing proposal. As he told Libre Graphics World, however, he is hoping to put together a plan for GNOME 3.4 that will incorporate colord support into Mutter, the GNOME compositing manager, but it is likely to involve changes to GTK+ and other parts of the stack as well.

Color-management is not something that can be completely automated, but desktop Linux is on track toward the next best thing, that the choice of sane defaults is automated. Colord effectively moves color-awareness out of the application space and down to the session level. For most people, on modern video hardware, an automatically-detected display profile will provide a "good enough" color balanced experience. The list of applications taking advantage of it is short, but growing, but the color geeks need not frown — as was the case before, those who are interested in hand-tweaking their color matching can still dig into the details and customize the experience.


(Log in to post comments)

Integrated color management with colord

Posted Sep 28, 2011 19:36 UTC (Wed) by daniels (subscriber, #16193) [Link]

The problem with the NVIDIA binary drivers is that they <em>don't</em> support RandR 1.2, which allows per-display gamma tuning. Some recent additions to the RandR spec for 1.4 mean they should hopefully be supporting it soon, though. Or just use nouveau. :)

Integrated color management with colord

Posted Sep 29, 2011 0:12 UTC (Thu) by alankila (subscriber, #47141) [Link]

Gamma is not sufficient anyway. A general strategy should support color wheel rotation. I think the earlier color management article hinted that the strategy is approximately as follows:

- make a 3D texture per display that provides mapping between the sRGB color space and the monitor's distorted RGB space.

- as the last step of composition, read the sRGB color triplets from the framebuffer, and replace them through interpolated 3D lookup through the above texture.

The suggested size for this texture was 16x16x16 texels, so 4096 values and 4 bytes per value giving 16k size for the look-up table in its most simple form. However, there are banding artifacts that appear when colors are quantized this way, so to avoid them it may be necessary to dither the result. Dithering the image properly needs more than 8 bits of precision per component to do.

Integrated color management with colord

Posted Sep 28, 2011 22:13 UTC (Wed) by quotemstr (subscriber, #45331) [Link]

Why a daemon and a SQLite database instead of a simple collection of files in a well-known location?

Integrated color management with colord

Posted Sep 29, 2011 0:53 UTC (Thu) by rpkelly (guest, #74224) [Link]

The daemon is presumably so it can be used over D-Bus. As for the choice of SQLite vs. files, I'm not sure.

Integrated color management with colord

Posted Sep 29, 2011 7:49 UTC (Thu) by michaeljt (subscriber, #39183) [Link]

> The daemon is presumably so it can be used over D-Bus. As for the choice of SQLite vs. files, I'm not sure.

I thought (but may be wrong) that DBus was able to start helper applications in response to queries rather than requiring the helpers to be already running as daemons.

Integrated color management with colord

Posted Sep 29, 2011 11:32 UTC (Thu) by rpkelly (guest, #74224) [Link]

Indeed it can. But, it is probably more responsive by starting it and leaving it running as a daemon. Especially since this is a core dependency of GNOME 3.2, one would assume that (in the future) many applications will be making use of it.

Still, I thought the original commenter was suggesting no helper application at all, but instead a shared library. Correct me if I'm wrong, though.

Integrated color management with colord

Posted Sep 29, 2011 2:13 UTC (Thu) by malcolmt (guest, #65441) [Link]

An SQLite database *is* a simple collection of one file in a well understood format. Accessible from other programs readily (SQL isn't that hard), including command line access via the relatively small sqlite3 binary. It falls down slightly on the "can't be edited with ed" test for text files, but apart from that it's an ideal choice for things like this. This really introducing some kind of opaque data format and it saves on having to write yet more code to parse text files that can be messed up by random editing (sqlite3 enforces sensible saving format to disk).

There are always going to be people who want text files only removed from their cold dead hands as a data format, but it's 2011 already and we collectively have a few decades of experience in how fragile text file editing can be (and well-known locations tend to be different locations even amongst different Linux distributions). This is a exceedingly minimal extra layer with some quite large benefits. I'm encouraged to see it happening more and more.

Integrated color management with colord

Posted Sep 29, 2011 3:12 UTC (Thu) by pabs (subscriber, #43278) [Link]

I've personally considered writing an LD_PRELOAD library for apps that use sqlite just so that non-text files never touch my ~/ and I can continue version control it with git in a meaningful and useful way. I find the way most applications on GNU/Linux distributions treat ~/ as offensive.

Integrated color management with colord

Posted Sep 29, 2011 3:32 UTC (Thu) by jimparis (subscriber, #38647) [Link]

To make git happier, maybe you could use a textconv filter to convert sqlite databases into SQL dumps, so at least diffs are meaningful.

Integrated color management with colord

Posted Oct 6, 2011 11:37 UTC (Thu) by Wol (guest, #4433) [Link]

The treatment of ~/ - AO b****y L!!!

If system config files go in etc, then personal configs should go in ~/etc or ~/.etc!

Not that mirroring the system setup in ~/ is a good idea, but it's a lot better than the current free-for-all!

Cheers,
Wol

User config location

Posted Oct 8, 2011 17:23 UTC (Sat) by grawity (guest, #80596) [Link]

Do you mean ~/.config? Many programs already use it.

Integrated color management with colord

Posted Sep 29, 2011 7:50 UTC (Thu) by michaeljt (subscriber, #39183) [Link]

> ...and well-known locations tend to be different locations even amongst different Linux distributions...

Surely using DBus for querying the data addresses that.

Integrated color management with colord

Posted Sep 29, 2011 12:27 UTC (Thu) by dmk (subscriber, #50141) [Link]

And, not to forget, it also decouples the colormanagment deamon from the applications. If you want to change the implementation of colord to not use sqlite, that is much easier with dbus accessed colord than it would, say, with a shared library.

Integrated color management with colord

Posted Oct 4, 2011 10:39 UTC (Tue) by juliank (subscriber, #45896) [Link]

> If you want to change the implementation of colord to not
> use sqlite, that is much easier with dbus accessed colord
> than it would, say, with a shared library.

If you designed the library correctly, there would not be any difference in the complexity of changing the format. If you expose sqlite3 types in your library, you did something wrong.

Integrated color management with colord

Posted Sep 29, 2011 20:54 UTC (Thu) by kleptog (subscriber, #1183) [Link]

As a bonus they've handled the crash reliability for you, so you don't need to worry about inconsistent or corrupt files...

Integrated color management with colord

Posted Oct 5, 2011 7:34 UTC (Wed) by cmccabe (guest, #60281) [Link]

One thing that I think some people are missing is the difficulty of debugging and maintaining complex systems.

I have experience debugging a large software suite with a couple of daemons that communicated using CORBA. I also have debugged the combination of NetworkManager, the desktop manager, wpa_supplicant, and the kernel. In both cases, using remote procedure calls made it a lot harder to figure out what was going on.

If you're using D-Bus or CORBA, you'll need special tools just to observe the messages that are going over the wire. Sure, they're out there, but you'll have to install them and learn them. Then you'll need to get debug versions of all the relevant programs, and make sure that you've restarted all the daemons involved. After that, you'll need some way of correlating log messages between the various programs. If you're lucky, the programs will include timestamps in their log messages that you can correlate with the timestamps in the d-bus output. If you're not, well, you'll have to hack the source.

When you've got asynchronous communication going on, you may very well have race conditions that appear and disappear in a frustrating way.

In contrast, if you were debugging an application that simply read a text file using a shared library, you could probably get pretty far with just "strace <program-name>."

Similarly, UNIX programs should really consider using text files to store configuration. Text files fit in with the rest of the UNIX system-- they can be grepped, rewritten with sed and awk, and so forth. They can be versioned with git or svn, and they take up very little space. If you search on Google, odds are that you will find helpful people who have pasted their text configuration files for you to copy.

However, if the program stores its configuration in, for example, sqlite, most people will not know how to get access to the information in that file, let alone modify it. Yes, in a perfect world, they would be proficient in how to use the SQL language, the application's schema, and the dumper tools, but ours is not a perfect world.

There are some cases where D-Bus and SQL databases are the right solution. But programmers need to stop to think that just because they can, doesn't mean they should.

Integrated color management with colord

Posted Oct 6, 2011 13:44 UTC (Thu) by n8willis (editor, #43041) [Link]

It seems like some people are confused about this issue. Colord does not store its configuration in the SQLite db; it stores it in /etc/colord.conf. The db does not store the actual ICC files either; those are in the profile directories mentioned in the article.

The SQLite db stores the *mappings* between devices and the various profiles assigned to them (including the fallback ones). By storing them in a database, the daemon can perform real queries on the various properties of said mappings, in addition to just a trivial (and static) DeviceX:ProfileY.

Nate

Integrated color management with colord

Posted Oct 7, 2011 9:21 UTC (Fri) by dgm (subscriber, #49227) [Link]

Very nicely said. It's a pity it's just false...

1. All files are subject to corruption. A text file is "fixable". A database file is not. It's gone. Forever. You cannot even read it.

2. Many times database formats are used for speed. The only problem is that for sequential reading, a text file is far faster than any database. Go ahead, test it.

> but it's 2011 already

So what?

Integrated color management with colord

Posted Nov 14, 2011 20:25 UTC (Mon) by job (guest, #670) [Link]

Yes, it's 2011 already. Your computer slurps a hundred lines of text based configuration in a millisecond. You won't even notice. There's absolutely no need to serialize these things in binary any more.

It's both easier and more robust than loading it from an sqlite driver, and you're going to stuff it in your own memory structure anyway.

Integrated color management with colord

Posted Sep 29, 2011 11:32 UTC (Thu) by cortana (subscriber, #24596) [Link]

A bunch of text files would have to be read in and parsed when the daemon starts up. A database format eliminates this problem, and SQLite in particular means that it's easy to migrate the on-disk data when the schema changes.

Integrated color management with colord

Posted Sep 29, 2011 12:49 UTC (Thu) by dlang (✭ supporter ✭, #313) [Link]

sorry, the database on-disk format also needs to be read in and parsed. it doesn't store a language specific memory structures in the database.

Integrated color management with colord

Posted Sep 30, 2011 7:31 UTC (Fri) by GhePeU (subscriber, #56133) [Link]

The next rung down on the quality ladder is manufacturer-provided profiles.

Since I started reading about color management in Linux (a few years ago, IIRC when somebody released 'xicc', who could preload a profile and then Eog could use it) I never found a good manufacturer profile.

Maybe I've got something wrong in my eyes or I'm ruined by years without color management, because all the profiles I tried (for LCDs by Samsung, Philips, Acer and Sony) changed the standard RGB blue in something that I could only describe as "violet" or plain white in yellowish white, so in the end I usually disable CM again and make do without it.

Integrated color management with colord

Posted Sep 30, 2011 17:44 UTC (Fri) by rahvin (subscriber, #16953) [Link]

There could be something wrong with hardware you've used but the mostly likely explanation is that you are used to systems running at a much bluer white point than exists in nature. OEM's tend to set the default white point on their hardware to a very blue 6500 or 7500K because it looks better in environments lit with fluorescent lights. People don't realize how distorted it is until they compare it against real world imagery or a properly calibrated display. A properly calibrated display will feel like the whites are yellow hued to start with. After a while of allowing your eyes to adjust when you look at an uncalibrated display you will be astounded how blue the whites are.

My experience is that the manufacturer provided ICC files aren't worth much against spectrometer calibrated displays. And color calibration spectrometers aren't very expensive.

SELinux tangent

Posted Sep 30, 2011 20:06 UTC (Fri) by robbe (subscriber, #16131) [Link]

> SELinux will not allow a system daemon to load files [...] from a user's home directory

Having read some more opinions about SELinux being useless in the postgres announce thread, I must say that I consider this a very nice effect of it. During its early days I spent some time writing SELinux policy for applications, and was appalled at the many violations against POLA that a typical one has.

If wider deployment of SELinux and its reference policy helps foster a more secure programming culture: bring it on.

> [...] pack a colorimeter and IT 8.7 target into the "booth box" when heading to community Linux shows.

The USD 100 or so, could also be money well spent for a local LUG or hackerspace.

Integrated color management with colord

Posted Oct 18, 2011 12:19 UTC (Tue) by oy (guest, #80450) [Link]

The article confuses wishful thinking of Hughes with real facts. We wait on the OpenICC list since months for the evidence brought up by Hughes of identical EDIDs being used by different manufacturers for different equipment. That argument comes out of the blue and is not verified by anyone.

About the hard requirement of root rights to obtain user settings was already annotated. IMHO it is dangerous and leads to a fuzzy architecture. Every nonsense can be hidden behind root transforming even the moon into a square. For instance local print settings can not be transported to a remote place by root. The actual user can change. Then the print queue can still have jobs from the old user. Now the root daemon has to decide to use the non logged in user settings or take the actual user with possibly completely different settings. That is confusing. That logic is similar to appending an email to each PNG image in order to describing the belonging ICC profile. But we, and the applications we use, learned to embed the ICC profile right into the PNG. It is much robuster.

A last comment about the used encrypted DB. ArgyllCMS stores its data base inside JSON text files. Oyranos CMS is very likely to join on a common namespace and set of keys.

Copyright © 2011, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds