This specification covers Adobe Photoshop gradient files (.grd) as of Adobe Photoshop 9.0 (CS2). This is the result of clean-room reverse engineering, that is: we created a sample gradient file, analyzed it, created a parser to dump the contents into a readable form and figured all the stuff out by creating new sample files with slightly changed settings. No .dll files were disassemled or even looked at.
Adobe Photoshop is a trademark by Adobe Systems Incorporated.
1. What codepage is used for storing text. Please tinker with my-noise-gradient-lab-cyrillic-name.grd (the name is "Шумный градиент в ЛАБе"). The my-custom-gradient-3-pantone.grd also contains an (R) symbol after "Pantone" — might be helpful.
2. Search for "unknown" in the text :)
Just like brush files, gradient files in Photoshop can contain multiple items. The structure seems to be linear, e.g. name of a gradient preset triggers its beginning.
There are two types of gradients: solid and noise ones.
Because contents of a gradient file depends of things like type of gradient or type of color stop, we do it like this: we list sequence of data on higher level, then sequence of data on lower level, branching out on types.
GrdL VlLs 19
Objc GradientGrdn 1
The dump belows lists amount of groups of entries.
Grad Objc GradientGrdn 5
The obe above is for solid gradients, the groups would be:
See below for details
This one is for noise gradients:
Grad (Objc) Gradient Grdn 9
The groups would be:
See below for details
Name of preset starts a new preset, see below.
Nm TEXT My Solid Color Gradient 1
Can be Solid or Noise, see below.
See below
GrdF enum GrdF CstS
In the UI is expressed in %, but internally it is saved as a variable with max value of 4096. Example:
Intr doub 3645.0, corresponds to 89%.
Photoshop gradients can have both opacity stops and color stops, so a gradient can vary in color and opacity. For example, there can be 5 color stops and 8 opacity stops.
Inside a preset color stops are listed first, opacity stops are listed next. See below.
Amount of color stops is defined in the beginning as:
Clrs VlLs %VALUE%, where %VALUE% is amount of color stops.
The block of a color stop starts with
Objc Clrt %VALUE%, where %VALUE% is 3 for foreground/background color stop and 4 for a user defined color stop.
There are three types of color stops in Photoshop:
Value | Description |
FrgC | foreground color, any current foreground color is used |
BckC | background color, any current background color is used |
UsrS | user defined color |
In the dump the switcher looks like this:
Type enum Clry %VALUE%
Those two kinds of stops containg only two values:
In the UI it is expressed in %, but internally it is saved as a variable with max value of 4096. Example:
Lctn long 694, which means 17%.
Mdpn long 50
These ones have a little more data:
They start with
Objc Clrt 4
Then goes an entry that defines color model:
Clr Objc %VALUE% %NUMBER%, where %VALUE% is either HSBC, RGBC, LbCl or BkCl. The %NUMBER% values defines of subsequent entries that define the color, like color channels.
Then goes a block with data for every channel of a chosen color model. By default HSB is used, and if you choose a different color model in the color chooser dialog and do not change anything, the value will still be written in HSB notation system. You can also define CMYK value in %, but the value will be written in either HSB, LAB or RGB, depending on where the radiobutton is.
For HSB:
H UntF #Ang 59.9963378906For RGB:
Rd doub 235.996108949For LAB:
Lmnc doub 96.08If you choose a color from a library like Pantone's, you get:
Clr (Objc) BkCl 4
Which, as noted above, defines amount of subsequent entries regarding color's definition. And then you get:
1. Name of the color book:
Bk (TEXT 18 ) TOYO Color Finder
2. Name of the color in the book
Nm (TEXT 10 ) TOYO 0213
3. ID od the color in the book:
bookID (long) 3006
4. Key of the color in the book, which is, basically, shorter name of the color:
bookKey (tdta 6 ) 0213
Funnily enough only then type of the color stop is written:
Type enum Clry UsrS
In the UI it is expressed in %, but internally it is saved as a variable with max value of 4096. Example:
Lctn long 2048
Color midpoint balances distribution of colors between two adjacent color stops and is expressed in %. The fun part is that location of a midpoint on the widget is controlled via the very same "Location" input field as for color and opacity stops, but the actual data is really written in percents:
Mdpn long 50
Amount of opacity stops is defined in the beginning as:
Trns VlLs %VALUE%, where %VALUE% is amount of opacity stops.
The block of a opacity stop starts with
Objc TrnS %VALUE%, where %VALUE% always seems to be 3.
In the UI opacity is expressed in %, it really is:
Opct UntF #Prc 100.0
In the UI location is expressed in %, but internally it is saved as a variable with max value of 4096.
For example max position, which is 100% in the UI, is displayed in the dump as: Lctn long 4096
Whereas 99% is: Lctn long 4055
Opacity midpoint balances distribution of opacity between two adjacent opacity stops and is expressed in % in both UI and actual data:
Mdpn long 50
GrdF enum GrdF ClNs
Tooltip says: "Add transparency noise to this gradient". This is a boolean value:
ShTr bool %VALUE%, where %VALUE% is 0 (checkbox off) or 1 (checkbox on)
Tooltip says: "Prevent colors from oversaturating"
This is a boolean value:
VctC bool %VALUE%, where %VALUE% is 0 (checkbox off) or 1 (checkbox on)
The tooltip says: "Set the available color range"
ClrS enum ClrS %VALUE%, where %VALUE% is RGBC (RGB), HSBl (HSB) or LbCl (LAB).
There is no inoput for the seed, just a "Randomize" button to randomize the gradient.
RndS long 52332The tooltip says: "Adjust gradient roughness". In the UI it is expressed in %, but internally it is saved as a variable with max value of 4096. Example:
Smth long 2458, which is 62%.
In the dump there are four pairs of min and max values: three pairs define min and max value for each color channel and the last pair presumably defines alpha channel. Min value for the presumably alpha-channel pair is always 0 and the max value is always 100.
It goes like this. First it defines amount of min values:
Mnm VlLs 4
Then it lists them obe by one as long.
The it defines amount of max values:
Mxm VlLs 4
And lists all four max values as long.
Text of this specification is licensed under terms of CC Share-Alike 3.0