|
ColorSync in Mozilla
A Project to build Cross-Platform Color Management
into the Mozilla Browser
As web publishing and commerce continue to rise in importance, a way of
managing colors from the source to the destination becomes an essential
feature of a browser. Specifically, the source image that is kept on a
web server will look different on various displays that access it as part
of the html stream, unless something is done to compensate for the various
viewing conditions. ColorSync is an Apple Computer technology that is widely
adopted in the print and graphic arts industries, and it is designed to
perform the necessary tasks of compensation for different devices. The
combination of a browser and ColorSync means that not only can people visit
sites such as art archives and see what the artist intended, they can order
products from online catalogues and not be surprised with the color when
it arrives in the mail.
ColorSync Building Blocks - ICC Profiles
ColorSync relies on device "profiles" to be able to account
for different device characteristics - these are files which have a format
specified by the International Color Consortium - they contain data for
a given device or class of devices.
The following file formats support embedded ICC profiles:
- TIFF
- JPEG
- GIF
- PNG
- PICT, and possibly more
Thus, a browser accepting files in these formats can detect embedded
profiles and use them to match from the source device colors to the display.
Support for this type of matching already exists in Internet Explorer 4.0.1.
In addition, with extensions to the HTML <IMG> and <BODY>
tags, profiles can be associated with images instead of having to
be embedded within. Details of the additional HTML tags and a sample site
testing browser use of images with profiles can be found at Apple's Colorsync
web site at colorsync.apple.com.
The benefits of profile association vs. embedding is that the profile
can be downloaded once and used for multiple images on a page, or in a
session. It also gives web site developers some flexibility, they don't
need to rewrite all their images to embed profiles, they can make some
simple additions to their HTML instead. GoLive's CyberStudio 3 allows for
content developers to use either profile association or embedding to enable
color management.
What has been added to Mozilla
The new code that has been added implements color management for images
that contain or reference ICC profiles, using ColorSync. It is not
a public release of ColorSync code, rather it is code that calls ColorSync.
ColorSync has been a component of MacOS for some time now - in the future
it will run on other OSes as well. The new code checks for the existence
of ColorSync on the OS, and if so will use its services as the browser
encounters images with ICC profiles. As noted, images can either contain
or reference ICC profiles. Therefore we first had to add smarts to the
image decoders (e.g. JPEG) to look for embedded profiles. Secondly, we
had to add new code to make requests over the net for ICC profiles referenced
by URLs (or local files). This code keeps track of whether a profile has
been received already and skips the download if so. Finally, code and user
interface elements have been added to turn on/off these new features via
preferences.
Current status of the project
Apple and Mozilla/Netscape engineers discussed many of the issues involved
in adding this functionality, with a rough spec drafted and revised. The
timing was such that if the additions were to have any chance of being
picked up into timely future versions of the browser, it had to be done
quickly - so as the opportunities for outside help faded Apple bit the
bullet and started writing code, after further consultations with various
module owners.
Since ColorSync now runs (alpha stage) on more than just the Mac platform,
we decided to place as much of the functionality in the cross-platform
image library as possible, with calls to the front end being used only
as a hedge against our being able to deploy ColorSync everywhere Mozilla
deploys. As the code currently stands, both the Mac and Win FEs have the
same set of new IMGCB entry points, and the code therein is also identical.
The X FE has stubs for these IMGCB entry points.
Here's what has been done so far:
- Embedded profile support for JPEG, GIF
- <IMG... ICCPROFILE=...> support
- <BODY... ICCPROFILE=...> support
- Preferences support : {no matching, match if profile, match to default}
- Printing works because the images are matched during decode time.
What's not there yet (for the future?)
- Color World caching (code there, not tested so turned off)
- Embedded profiles in PNG
- Other color management features, like preview
Changes were made mostly to the image lib, expanded structs and new
calls to a set of routines in a new file: icc_profile.c. I also had to
change some code in layout, to parse the new IMG and BODY tags. Finally,
in addition to the front end code and additional IMGCB entry points, we
added new 'ppob' resources to the Mac resource file. This enables the new
preferences, code was added to the image lib to read them.
What can you do?
The list above mentions color world caching and profiles in PNG. The
PNG spec for embedded ICC profiles has just been adopted by the PNG working
group. It is available for download at the following sites:
http://www.cs.berkeley.edu/~amc/png/
http://www.cdrom.com/pub/png
For this project, code was added to the jpeg and GIF reader routines
in the imagelib - similar code would have to be added to the PNG reader.
As far as "color world" caching goes, this is a similar optimization
to image caching (in memory), and it means keeping around table information
built from a set of ICC profiles with the idea of being able to use the
information again. This is a good idea if the source (input) and destination
(output) profiles are expected to be the same for multiple images - a valid
assumption in some cases. There is code in the new file that is designed
to implement this, but it is not turned on yet.
Finally, here is a brief, undetailed list of some other things that
could possibly be done:
- Profile embedding/association in composer
- Figure out how to get AVID (Mac) for MWContext
- Print preview with ColorSync
- Gamut-check mode
- Display list of profiles embedded or assiocated on the current page
(I'll probably have to implement this at some point just for debugging)
If you're interested in helping further ColorSync support in Mozilla,
by all means contact me or others in Mozilla.org. Thanks.
Eric Broadbent
ebb3@apple.com
August 31, 1998
|