Weekend Project: Tackle Color Management on Linux

1784

 

Do you see what I see? Maybe, if you have taken the time to tackle color management on your machine. The major desktop environments for Linux give 90 percent of users all the tools they need to see all of their images in device-independent accuracy. You don’t even need to buy special hardware. This weekend, pull up a monitor and see what all the technicolor fuss is about.

I’ll be the first to admit that I write about color management more than the average Linux user cares to hear about it. I mention it whenever I review graphics apps for two reasons: first, because it is a must-have feature for photography and graphic design, and second, because desktop Linux is right on the verge of making it simple and ubiquitous, which will be a major win. But it is not quite point-and-click simple yet. But it’s not pulling teeth difficult anymore, either.

For those totally new to the subject, the essence of color management is that no two devices produce exactly the same colors, but because all digital colors are nothing more than numbers (think RGB triples…), we can mathematically convert each number so that when it finally reaches the screen, it looks the same. Theoretically, the only trick is knowing the characteristics of the monitor — what part of the the 3D color space it can actually display.

Practically speaking, there is another tricky part: the application that wants to paint the colorful pixel onto the screen needs to actually do the transformation, not just shove raw RGB at the X server. But that’s a problem for application developers; there are libraries to make short work of the number crunching, and a shockingly long list of Linux apps is already prepared to pretty-up your colors if you’ll just provide the display characteristics.

And therein lies the work. In years past, the task of creating the “display profile” (as it is officially known) was both complicated and arcane. You needed a light-sensing colorimeter that you could stick onto your monitor, and you needed to work a suite of command-line tools (which never seemed to be packaged for your distribution) to put the monitor through its paces and capture its behavior with the colorimeter. Not to mention that supported colorimeters were not cheap or easy to find. Besides, it seemed like no one would ever notice “color problems” unless they had two monitors, which is a small minority of Linux users.

The last problem is the one that changed first. Netbooks came along, laptops got cheaper, and even people who only had room on the desk for one monitor found themselves regularly looking at two or more different displays and getting frustrated when they couldn’t make their Facebook profile photos look right on both of them. One of those people happened to be GNOME’s Richard Hughes, who sat down and wrote the first non-color-geek’s color management app for desktop Linux, GNOME Color Manager (GCM).

Getting Started: GCM and Profiles

GCM and ProfilesGCM is an official GNOME project, and should be available on GNOME 2.28 and later. Fedora, openSUSE, and Ubuntu all package it, and it is supposed to be a default module in GNOME 3. Check with your distribution’s package management system. The current stable release is 2.32, and when installed, it appears in the menu structure as System -> Preferences -> Color Profiles.

The main window has three tabs: Devices, Profiles, and Defaults. Look at Defaults first. There are two checkboxes under the “Display” section; one to apply correction and one to set a system property that color-aware applications can ask to get info about the default display. Check both. The first one is what actually adjusts the monitor output (which is the whole point of color management), while the second saves you the trouble of having to manually configure most of the other applications you want to use. You will probably want to set the RGB “Working space” setting to sRGB and the “Rendering intents” to Perceptual. sRGB is the standard everyone uses, and Perceptual just means the numerical conversions are designed to “look right” rather than fit some particular color model.

If you go back to Profiles, you will see a list of ICC Color Profiles that the operating system already knows about. Most of these are pre-defined standards like sRGB or NTSC (the color profile used by broadcast television in North America). GCM picks them up from the /usr/share/color/icc/ system directory. You can look at a graph that overlays the selected profile on top of the gumdrop-shaped full-human-eye color space by clicking on the “Profile Graphs” button. At the bottom of this list you will find “conversion profiles.” These are the transformations from one colorspace to another used for calculations — you don’t need to worry about them at all.

Now click on Devices. The list on the left shows all of the hardware GCM knows about, input and output. For our display-oriented purposes, this includes all of the X “Monitor”s defined in your /etc/X11/xorg.conf file. You will see them listed by the VendorName and Identifier settings taken directly from that file. All GCM needs in order to properly color-correct for your monitor (or monitors) is for you to select the proper profile from the drop-down list on the right-hand side of the window. The correction will take effect immediately, and you can make it a system-wide setting by clicking “Make Default” at the bottom.GCM Devices

So where does the “proper” profile come from? That is a matter of how much effort you want to put into the task. Color purists will tell you that the only proper profile is one that you generate yourself, with a colorimeter and profiling software. That is technically the most precise, since no two devices are alike, and here there is good news: colorimeters have gotten much cheaper, particularly because Linux support for low-cost USB devices has improved significantly.

If you do pick up one of the cheap USB colorimeters, you can plug it in now and GCM’s “Create Profile for Device” button will light up, allowing you to create a custom profile for your selected monitor. But since this is a weekend project for everyone, let’s take a look at your other options — the ones that don’t require buying any additional hardware.

Faking It Till You Make It

It may be controversial in some circles, but if you can’t create your own custom display profile, I recommend trying to find one specific to your model of monitor as a good “next best thing” starting point. You might already own one: in many cases, manufacturers include display profiles among the auxiliary files and drivers that they include on the CDs packaged in the box with the warranty card and user manual. If you still know where yours is, find it, dust it off, and pop it in — an .icc or .icm file is all you are looking for.

If you can’t find it, try the manufacturer’s support site, under the drivers and downloads section. You can also find user-contributed display profiles for common monitors if you search photography and design forums. A profile created with a hardware colorimeter is independent of the OS used to create it, so a Windows or OS X user’s profile is perfectly fine if they’re willing to share it.

Wherever it comes from, you can install the profile in GCM by moving to the Profiles tab and choosing “Import.” GCM will copy it from the CD to the ~/.color/icc/ directory. This gets you part of the way there, but it is imperfect because even two monitors of the same brand and model can differ significantly in their actual characteristics. Take a look at the two display curves below: they are from two identical Dell monitors of exactly the same age, but they are far from identical. But with the manufacturer-provided display profile, you do at least get the correct color primaries and some other characteristics that you will not be able to figure out by eyeballing it.

GCM CurvesFinally, even if you absolutely cannot find a display profile for your monitor, you can use another application to approximate what you see. KDE’s Kgamma is a GUI tool built for KDE4’s systemsettings app (what used to be called KDE Control Center). Kgamma is designed around changing the X server’s gamma-ramping settings, which is not the same as a display profile, but it works because GCM doesn’t touch gamma ramp setting either. You can select a generic display profile in GCM, then use Kgamma’s color and gray-scale test images to manually adjust your monitor’s gamma correction. The result is not as good as a colorimeter, of course, but if you are careful it works for your eye … which was the original point, after all. Kgamma even lets you independently adjust multi-head displays.

Applications and Video Drivers

GCM’s “set profile for color managed applications” checkbox saves the selected display profile as the _ICC_PROFILE setting in the X server. Any application can query that setting and automatically pick up the correct profile to use when displaying images. The ability to share display profile information across the desktop is small but important step towards completely automatic color management; there is more work to bring color management to lower-level components like GTK+, Cairo, and Compiz.

Currently GIMP, Inkscape, Geeqie, and Krita will query the system for a display profile automatically. Other color-aware applications like Digikam, Rawstudio, and Scribus require you to select the color profile from a list in their application’s settings window. Firefox requires you to browse to about:config then manually change the gfx.color_management.display_profile setting, selecting your profile from the filesystem.

Those are among the most widely used applications that benefit from great color content, and it is remarkably less work to set up than it was just two years ago. But that doesn’t mean it’s as easy as falling down, either. You can still get bit by some aggravating bugs thanks to that age-old enemy of usability, the X server. Specifically, if you use a multi-monitor setup with an Nvidia graphics card, you cannot have both 3D acceleration and per-monitor color profiles. That’s because the non-free “nvidia” video driver does not support per-monitor profiles, and the alternative free “nouveau” driver does not support 3D acceleration. Thus you are stuck with an uncomfortable choice: either give up one feature, or by yourself an ATI or Intel video card. Or just wait, and throw some support to the nouveau developers. That’s probably the best free-software-community-building option.

If you want extra credit in this field, I suggest checking out some of the more advanced color profiling tools, like dispcalGUI, which can create very high-profile display profiles including ambient lighting correction. It is also a good introduction to the Argyll color management suite, which is one of those command-line oriented utilities mentioned in the introduction. It is still CLI, but the documentation is first-rate.

In some ways, color management sounds exotic, but I really think that’s just because Linux users have grown accustomed to living without it. With all of those transistors on the GPU, and CPU cycles spinning around, we expect our OS to do a lot of low-level work for us, including redrawing the screen without jitter and tearing, anti-aliasing our fonts, and rendering drop-shadows under our windows. It really ought to be making out colors look correct no matter what monitor we plug in, too. Good thing it’s not as complicated as it sounds; we might get there before you know it.