Background

Color palettes in CorelDRAW are implemented using external files that hold all the color information for the palette. Prior to version X5 these files were stored in a proprietary binary format with a .cpl extension. In X5 they were changed to an XML format so that they are more readable and extensible. While you can create a palette entirely through the user interface of CorelDRAW or Corel PHOTO-PAINT, there are scenarios where you may want to create one from existing data from a spreadsheet such as a vendor color swatch book data, thread color data, etc. This article describes the new format and give some information how you can create one yourself.

Location

The color palette file is a completely standalone XML file. This allows it to be easily added to the appropriate folder to be use in both CorelDRAW and Corel PHOTO-PAINT without any other changes. The applications look in two main locations for their palettes: the installed subfolder called Color\Palettes and the user's My Palettes subfolder in their Documents folder.

Palettes from the install folder cannot be changed by the user from within the application and appear under the "Palette Libraries" section in the Color Palette Manager docker. If you wish to place your palette here, you need to have the appropriate rights to modify this folder.

User palettes from the My Palettes subfolder are modifiable by the user and show up in the "My Palettes" section in the Color Palette Manager docker. To help you get acquainted with the new file format, you may wish to browse through the installed palettes and see how they are structured. Double clicking on the XML file should open in the default application (like Internet Explorer) where you can view it.

The next section describes the new format in detail, if you want to get right to creating your own palette from existing data you can skip to the "Creating a Color Palette From Existing Data" section below.


XML Format

High Level Overview

The XML format has a root palette element under which is all the data. On the palette element are attributes that describe the palette itself like its name, unique GUID identifier, etc. Under this element there are three main sub elements: colors, colorspaces, and localization.

The colors node define the actual color swatches that appear in the palette. The colorspaces node define the various color space models that the colors can use. Supporting translated text names is done through the use of the localization node. The file snippet below gives an example of this structure.

<? version="1.0" ?>
<palette name="Example Custom Palette" guid="ec120aef-24cf-42dd-ad25-491ea640e171">
    <colors>
        ...
    </colors>

    <colorspaces>
        ...
    </colorspaces>

    <localization>
        ...
    </localization>
</palette>

Next we'll dive in for a more detailed description of each element.

Palette Element

The palette element can have the following attributes:

  • guid - global unique identifier for the palette [required]
  • name - visible name for the palette [optional]
  • resid - resource identifier used if localizing the palette names [optional]
  • prefix - common color prefix used in the search color dropdown [optional]
  • locked - 'true' meaning the palette is locked and prevents user edits [optional]

The guid attribute defines the globally unique identifier that identifies this palette. It must be different for each palette. You can create a GUID using a 3rd-party tool, or website like http://www.guidgenerator.com/.

As the name suggests, the name attribute is the display name for the palette. If you want to have this palette display a name in the application's localized language, then you can use the resid attribute instead. This takes a GUID for a value and uses it to lookup in the localization section for the actual text to display. This will be discussed more when we get to the localization section.

The prefix attribute is used if the color names all have a common prefix that you want to allow the user to not have to type in the search color dropdown in the color dialog.   For example, if all colors begin with a company name, setting this as the prefix means the user won't need to type it each time they do a search.

Finally, the locked attribute indicates whether or not the palette is locked to user changes. If the palette is stored in the installed folder, then this attribute should be set to true since the palette cannot be changed anyways.  If it is in the user folder, then it gives you the flexibility to enable/disable edits.

Here is an example palette element with its attributes.

<palette name="Example Custom Palette" guid="ec120aef-24cf-42dd-ad25-491ea640e171" prefix="ACME" locked="true">

Colors Element

The colors element is the main section that defines all the color swatches that are displayed on the palette. The layout of the colors in the file can be done in two different ways: place all colors in a single page element or group them into multiple page elements. The later would be used to correspond to actual vendor swatch book pages.

If all the colors are listed on one page element you may wish to assign a width which would break up the palette into rows accordingly when the palette is displayed in the color dialog. This can be done by setting the width attribute on the page element. The default width if it is not set is 8 swatches per row.

If the colors are broken up into several pages then each page is displayed as a row in the color dialog. The advantage of doing it this way is that individual pages can have different number of colors to match the same layout of a swatch book of colors.

The example below shows all the colors listed on a single page with default width of eight swatches per row in the color dialog.

<colors>
    <page>
        <color cs="CMYK" tints="0,0,0,1" />
        <color cs="CMYK" tints="0,0,0,0.9" />
        <color cs="CMYK" tints="0,0,0,0.8" />
        <color cs="CMYK" tints="0,0,0,0.7" />
        <color cs="CMYK" tints="0,0.6,1,0" />
        <color cs="CMYK" tints="0,0.4,0.2,0" />
        <color cs="CMYK" tints="0,0.2,0.2,0.6" />
        <color cs="CMYK" tints="0.2,0.2,0,0" />
        <color cs="CMYK" tints="0.4,0.4,0,0" />
                    ...
    </page>
</colors>

Color Element Element

Within the page element is a list of color elements where each element represents a color swatch displayed in the palette. The attributes of the color element are as follows:

  • cs - color space of the color [required]
  • tints - comma separated tint values for each color channel in the range 0.0 to 1.0 [required]
  • name - visible name of the color [optional]
  • resid - resource ID for the localized color name [optional]

 The cs attribute defines the color space for the color. This can be any of the predefined color spaces or can refer to a custom color space that is defined in the color spaces section in the file. The predefined color spaces supported are the following: CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration.

In conjunction with the cs attribute is the tints attribute. This is a list of comma separated floating point values from 0.0 to 1.0 where each value represents the tint value for one of the channels in the color space. The number of tints required will vary depending on the color space used. CMYK, for example, needs four tints one for C, M, Y and K, whereas LAB only needs three. If the color space is a custom color space only one tint is required.

 For example, the element below defines a CMYK color with tints C=0.2, M=0.4, Y=0.0, K=0.4.

<color cs="CMYK" tints="0.2,0.4,0,0.4"/>

Defining a color from the Gray color space only requires one tint, for example,

<color name="50% Black" cs="Gray" tints="0.50"/>

The next example shows how to define a color that uses a custom spot color space with the tint of that one channel set to 1.0.

<color cs="MySpotColor" tints="1.0"/>

Similar to the palette element, a color element can have a name attribute or resid attribute. The name attribute is the display name that is used for the color. If the resid attribute is defined it will lookup the appropriate name from the localization section for the current user language that the application is using. This will be discussed in more detail when we cover the localization section.

Color Spaces Element

As described above, colors defined in the palette each refer to a color space model that they are using. This can be one of the predefined color spaces (CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration) or a custom color space. If you want to define your own custom color space like a spot color for a particular ink or thread color then you can define it in the color spaces section of the palette. If all the colors in the palette can be described using one of the predefined color spaces then the color spaces element is not needed.

The colorspaces element has no attributes itself but is simply a collection of individual colour space elements. Each colour space element, cs, defines the color space using various predefined color space representations. The snippet below gives an example of a few of these color space elements.

<colorspaces>
    <cs
name="MySpotColor1" fixedID="1">
        <color
cs="CMYK" tints="0,0,0.58,0"/>
        <color
cs="LAB" tints="0.9227,0.480039215686275,0.714196078431373"/>
        <color
cs="RGB" tints="0.968627450980392,0.92156862745098,0.490196078431373"/>
    </cs>

    <cs
name="MySpotColor2" fixedID="2">
        <color
cs="CMYK" tints="0,0,0.7,0"/>
        <color
cs="LAB" tints="0.9168,0.478470588235294,0.757450980392157"/>
        <color
cs="RGB" tints="0.968627450980392,0.913725490196078,0.384313725490196"/>
   
 </cs>
        ....
</colorspaces>
 

Color Space Element

A color space element, identified by a unique name, is typically used for spot colors, though can be used for process colors if required. The definition holds all the various ways to describe the color using the predefined colour space like RGB, CMYK, LAB, etc. The color space element has attributes that describe the color space as follows:

  • name - name of the color space [required]
  • fixedID - color space numeric identifier [required]
  • process - true meaning the color space defines a process color; false (default) meaning the color space defines a spot color [optional]

The name attribute defines the unique name for this color space. This is not a translatable name since it identifies the color space. Typically it will be the unique spot color name from a particular vendor.

The fixedID is an integer that uniquely identifies this color in this palette. It is used when storing spot color in the CDR file format and is therefore required. Note, if colors are added later to the palette, it is important that the existing fixedIDs do not change as CDR files may still be referencing them.

By default if the process attribute is not set, the color space will be treated as a spot color space definition. If the attribute is set to true it treats it as a process color space.

Color Elements for a Color Space

 Each color space will list one or more color definitions. These describe the color space under various color models. For example, the MySpotColor color space defined below is described using CMYK, LAB and RGB color models.

<cs name="MySpotColor" fixedID="1">
    <color
cs="CMYK" tints="0,0,0.58,0"/>
    <color cs="LAB" tints="0.9227,0.480039215686275,0.714196078431373"/>
    <color
cs="RGB" tints="0.968627450980392,0.92156862745098,0.490196078431373"/>
</cs>

These colors declare a color space model using the cs attribute. This color space must be from one of the predefined color spaces: CMYK, CMY, RGB, sRGB, AdobeRGB, HSB, HLS, YIQ, LAB, Gray, Hexachrome or Registration.

The other attribute for the color element is the tints attribute. As described earlier, this is a comma separated floating point series of 0.0 to 1.0 values representing all the channels for the particular color space. For example, if the color space is RGB, there will be three values one for R, G and B. If CMYK there will be four. The example above illustrates how to represent a spot color using three different color models: CMYK, LAB and RGB.

This may seem unnatural at first to set the channel values in a 0.0 to 1.0 range since we are used to seeing values in other ranges. This approach, however, simplifies all representations to a consistent range without losing any accuracy. We'll discuss this more later when we discuss how to convert your data into this format.

Localization Element

The last main section in the color palette file is the localization element. This element is optional but gives you the ability to localize all text in the file like the palette name and color names that are displayed in your palette. Instead of defining a name attribute for those elements, you define a resid attribute which stands for resource identifier. This is a GUID (globally unique identifier) that will uniquely define the resource text. Just like the palette GUID, you can create one using the http://www.guidgenerator.com/ website.

The example below shows the palette element with the resid attribute defined:

<palette guid="cccd19cb-4675-4a5e-8bda-d0bbbaab8af0" resid="38ab6302-92be-4839-85fa-ca2cff330fa4">

The next example shows how to define the resid attribute for a color element.

<color cs="CMYK" tints="0.2,0.4,0,0.4" resid="d886df8f-3914-46ad-8d99-e03fc2cc8a93" />

The localization element, then declares an entry for each of these resources identified by their matching id attribute. For example, the palette name and color name referenced above are defined below in different languages are supported.

<localization>
    <resource
id="38ab6302-92be-4839-85fa-ca2cff330fa4">
        <EN>
CMYK palette</EN>
        <BR>Paleta CMYK padrão</BR>
        <CS>
默认 CMYK 调色板</CS>
        <CT>預設 CMYK 色盤</CT>
        <CZ>Výchozí paleta CMYK</CZ>
         <DE>Standard-CMYK-Palette</DE>
         <ES>Paleta CMYK predeterminada</ES>
        <FR>Palette CMJN par défaut</FR>
        <IT>Tavolozza CMYK predefinita<IT>
        <JP>
デフォルト CMYK パレット</JP>
        <KR>기본 CMYK 팔레트</KR>
        <MA>Alapértelmezett CMYK paletta</MA>
        <NL>Standaard-CMYK-palet</NL>
        <PL>Domyślna paleta CMYK</PL>
        <RU>Палитра CMYK по умолчанию</RU>
        <SU>CMYK-oletuspaletti</SU>
        <SV>Förvald CMYK-palett</SV>
        <TR>Varsayılan CMYK Paleti</TR>
    </resource>

    <resource
id="d886df8f-3914-46ad-8d99-e03fc2cc8a93">
        <EN>
Grape</EN>
        <BR>Uva</BR>
        <CS>葡萄紫</CS>
        <CT>葡萄色</CT>
        <CZ>
Tmavě modrá červeň</CZ>
        <DE>
Traube</DE>
        <ES>
Uva</ES>
        <FR>
Raisin</FR>
        <IT>
Vinaccia</IT>
        <JP>
グレープ</JP>
        <KR>
포도색</KR>
         <MA>Otellókék</MA>
         <NL>Druif</NL>
        <PL>
Jagodowy</PL>
        <RU>
Виноградный</RU>
        <SU>
Rypäleensininen</SU>
        <SV>
Blåviolett</SV>
        <TR>
Üzüm</TR>
    </resource>

</localization>

The languages use a two letter language code as follows:

EN - English
BR - Brazilian
CS - Chinese Simplified
CT - Chinese Traditional
CZ - Czechoslovakian
DE - German
ES - Spanish
FR - French
IT - Italian
JP - Japanese
KR - Korean
MA - Hungarian
NL - Dutch
PL - Polish
RU - Russian
SU - Swedish
SV - Finnish
TR - Turkish

That's it for the XML format descirption. Attached to this article is an XML schema file that describes the file format which you can use to validate your palette using an XML validate.  Note: the file has a .txt added so that the blog would accept the file.  Just remove this before using.

Next we'll describe how to create one of these palettes from a spreadsheet of existing color data.

 


Creating a Color Palette From Existing Data

If you have existing color data stored in a spreadsheet, it is relatively easy to use this to generate the color palette using the attached perl script. This script expects the data to be in a particular layout which you will need to do within the spreadsheet program. Then just export the spreadsheet as a tab-separated text file and run the perl script on it to create the XML color palette.

The snippet below shows example color data lined up in the columns expected.  Note, this example has been padded with spaces to visually line up for ease of reading, but the perl script expects only one tab per column which is what you will get when exporting a spreadsheet of column data as a tab-separated text file.

Example Custom Palette
ACME
ec120aef-24cf-42dd-ad25-491ea640e171
Spot
Header info

Page IndexOnPage ColorSpaceID ColorSpaceName DescriptiveName   L*    a*     b*   R    G   B  C  M  Y   K
1         1             1         ACME 111     Light Yellow  92.27 -5.59  54.12 247 235 125  0  0  58  0
1         2             2         ACME 112     Medium Yellow 91.68 -5.99  65.15 247 233  98  0  0  70  0
1         3             3         ACME 113     Yellow        90.63 -6.18  91.38 249 230   0  0  0  95  0
1         4             4         ACME 114     Dark Yellow   89.36 -4.46  98.02 249 225   0  0  1 100  0
1         5             5         ACME 115     Tan           73.26 -1.01  81.58 203 179   0  5 10 100 15
1         6             6         ACME 116     Medium Tan    65.16 -0.51  73.05 179 157   0  7 13 100 28

Step 1 - Get the Data in the Correct Layout for the Script to Understand

The first few lines correspond to the attributes of the palette element in the XML file as described earlier.

Line 1 - PaletteName
Line 2 - Color prefix name
Line 3 - Palette GUID

Line 4 - Spot or Process
The colors in a palette can be defined as spot or process colors. If this line reads Spot they will all be treated as spot colors. If it reads Process they will all be treated as process. Once the palette is created, individual colors can be changed from spot to process and visa-versa by adding/removing an attribute on the colorspace definition.

Line 5-6 Extra header lines
Any extra custom data can be placed here. The perl script ignores these lines and they will not be shown in the application.

Line 7 - Column Headers
The perl script looks for these headers to know which columns have which data. Supported data for each color include:

Page
The swatch book page where the color is found. This is used to match vendors actual swatch books. If it is not needed, then all colors can be placed on page 1.
IndexOnPage
The color's index on the page. Again this corresponds to the swatch book page. If there is only one page then each color just needs to have a unique index.
ColorSpaceID
Unique integer representing the color space ID. This is a reference number used to look up the color in the palette. Once set, this number cannot be changed from version to version.
ColorSpaceName
Name of the unique color space. This is typically a vendor's product code representing the unique color. If no descriptive name is given, this is used as the visible name for the color.
DescriptiveName
Name of the color as it appears in the application in the status bar and tooltips. 
L* a* b*
Three sequential columns of the L*a*b* definition for the color space.
L* [0..100]
a* [-128..127]
bb* [-128..127]
R G B
Three sequential columns of the RGB definition for the color space.
R [0..255]
G [0..255]
B [0..255]
C M Y K
Four sequential columns of the CMYK definition for the color space.
C [0..100]
M [0..100]
Y [0..100]
K [0..100]
sR-255 sG-255 sB-255
Three sequential columns of the sRGB definition for the color space.
R [0..255]
G [0..255]
B [0..255]
aR-255 aG-255 aB-255
Three sequential columns of the Adobe RGB definition for the color space.
R [0..255]
G [0..255]
B [0..255]

Note: not all color models per color need to be defined, but if they are it will add them to the color space definition. When creating the color space definitions it will convert values from these ranges to the 0.0 to 1.0 range. This is typically done by dividing by the upper range value. For Lab values a and b, it also offsets the value since these can be negative. You can have a look in the perl script to see how it is done.

Step 2 - Generate the XML Palette File

The palette xml file is generated using the perl script (see link above) that parses the given palette text file to produce the XML file. Note: the attached file has .txt added to the name so that the blog would accept the file in the post.  Just remove this from the name before using.  A perl interpreter needs to be installed on the machine in order to use the script. One interpreter that is available on the web is called ActivePerl and can be found at http://www.activestate.com/activeperl.

From the command line run:

perl CreatePaletteXmlFromTxt.pl CustomPalette.txt CustomPalette.xml

This will convert the input text file CustomPalette.txt to the XML palette file CustomPalette.xml.

Step 3 - Placing the File

For the new palette to be part of the installed application, it can be placed anywhere under following folder:

<<Install Folder>>\Color\Palettes

Under this folder you can organize the palettes into subfolders as needed and this organization will be reflected in the user interface.  Once placed, the palette will be available through the Color Palette Browser docker in both CorelDRAW and Corel PHOTO-PAINT. Alternatively, if placed under the user's My Palettes folder in their Documents folder it will appear as a user palette in the applications.

Step 4 - Palette Lists (Optional)

There are several places where a short-list of commonly used palettes is displayed. For example, the Window-->Palettes menu, the interactive fill tool property bar with uniform fill selected, and the convert to paletted dialog. This list is predefined based on the region from which that the user is running. The list is found in the XML file:

<<Install Folder>>\Config\ColorPalettes.xml

The new palette can be added to this list by adding a new palette entry in the appropriate region with the GUID identifier used in the palette XML file. The palette name will be retrieved from the palette itself.

That's it! You should now be able to generate your own color palettes from existing data.

ColorPaletteSchema.zip
  • Hi! I create RAL spot colors. I try to change it to multilingual, but when i put the <localization> sequence at the end of xml file the corel palette will empty. The localization works just with the simple color sequence?

    The working example:

    <palette guid="EE37C43A-DCA6-4588-B814-BE3B5489FC69" name="Classic RAL palette"prefix="RAL  " locked="true">

    <colorspaces>

    <cs name="RAL 1000" fixedID="0" version="1500">

    <color cs="CMYK"  tints="0.1,0.1,0.5,0.1"/>

    <color cs="RGB"  tints="0.83921568627451,0.780392156862745,0.580392156862745"/>

    <color cs="LAB"  tints="0.761,0.499764705882353,0.606627450980392"/>

    </cs>

    </colorspaces>

    <colors>

    <page>

    <color cs="RAL 1000" name="RAL 1000 green beige" tints="1"/>

    </page>

    </colors>

    </palette>

    The localized version:

    <palette guid="E217C3EF-DC8C-47EA-8F0D-368182BAA67A" resid="66CEC945-359A-4355-984F-3CB1057C2A49" prefix="RAL  " locked="true">

    <colorspaces>

    <cs name="RAL 1000" fixedID="0" version="1500">

    <color cs="CMYK"  tints="0.1,0.1,0.5,0.1"/>

    <color cs="RGB"  tints="0.83921568627451,0.780392156862745,0.580392156862745"/>

    <color cs="LAB"  tints="0.761,0.499764705882353,0.606627450980392"/>

    </cs>

    </colorspaces>

    <colors>

    <page>

    <color cs="RAL 1000" resid="61F99F27-C24E-4BD5-9477-14FD0538B176" tints="1"/>

    </page>

    </colors>

    <localization>

    <resource id="66CEC945-359A-4355-984F-3CB1057C2A49">

    <EN>Classic RAL palette</EN>

    <MA>Klasszikus RAL paletta</MA>

    </resource>

    <resource id="61F99F27-C24E-4BD5-9477-14FD0538B176">

    <EN>RAL 1000 green beige</EN>

    <MA>RAL 1000 zöldbézs</MA>

    </resource>

    </localization>

    </palette>

    Can you help me where went wrong the above code?

  • script is not broken but the instructions than lines 5-6 are ignore are unclear. While the script might not use them they are required, even if empty.

  • This would be great... if it worked. The script incorrectly errors out stating:

    "error: missing IndexOnPage data"

  • This would be cool... if it worked.

    I keep getting the following error:

    "error: missing IndexOnPage data" even though it is present"

  • This is great knowledge. Thank you for detailed explanations.