4
4
Fork 0
This repository has been archived on 2025-01-20. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
json-photoshop-scripting/Utility-Scripts/Generate-Gradients-File
2024-02-24 13:35:32 +01:00
..
images First commit 2018-04-15 16:41:40 +02:00
Generate Gradients File.js First commit 2018-04-15 16:41:40 +02:00
README.md Fixed relative links in README.md files 2024-02-24 13:35:32 +01:00

Generate Gradients File

Description

“Generate Gradients File” is a gradients utility script using the JSON Action Manager scripting library.

This stand-alone script written in JavaScript is used to generate a Photoshop gradients file (.grd) from a JSON text file containing a JSON array of gradient objects, each one in Gradient Object Simplified Format.

From a technical point of view, it shows how to take advantage of the method ActionDescriptor.toStream to encode a flattened (serialized) version of an ActionDescriptor object saved in a file.

The utility script Parse Gradients File performs the reverse operation, i.e., converts a Photoshop gradients file (.grd) into a JSON text file containing a JSON array of gradient objects in Gradient Object Simplified Format.

Please refer to the Photoshop Gradients File Format page for detailed information about the structure of a gradients file.

Example

JSON text file (My Gradients.json) used as input to generate a gradients file:

[
    {
        "name": "Brass",
        "gradientForm": "customStops",
        "interpolation": 4096,
        "colors":
        [
            {
                "location": 0, "midpoint": 50, "type": "userStop",
                "color": { "red": 235, "green": 220, "blue": 35 }
            },
            {
                "location": 1024, "midpoint": 50, "type": "userStop",
                "color": { "red": 255, "green": 252, "blue": 194 }
            },
            {
                "location": 2048, "midpoint": 50, "type": "userStop",
                "color": { "red": 233, "green": 217, "blue": 28 }
            },
            {
                "location": 3072, "midpoint": 50, "type": "userStop",
                "color": { "red": 255, "green": 252, "blue": 200 }
            },
            {
                "location": 4096, "midpoint": 50, "type": "userStop",
                "color": { "red": 234, "green": 215, "blue": 32 }
            }
        ],
        "transparency":
        [
            { "location": 0, "midpoint": 50, "opacity": 100 },
            { "location": 4096, "midpoint": 50, "opacity": 100 }
        ]
    },
    {
        "name": "Blue, Red, Yellow",
        "gradientForm": "customStops",
        "interpolation": 4096,
        "colors":
        [
            {
                "location": 0, "midpoint": 50, "type": "userStop",
                "color": { "hue": 240, "saturation": 100, "brightness": 100 }
            },
            {
                "location": 2048, "midpoint": 50, "type": "userStop",
                "color": { "hue": 0, "saturation": 100, "brightness": 100 }
            },
            {
                "location": 4096, "midpoint": 50, "type": "userStop",
                "color": { "hue": 60, "saturation": 100, "brightness": 100 }
            }
        ],
        "transparency":
        [
            { "location": 0, "midpoint": 50, "opacity": 100 },
            { "location": 4096, "midpoint": 50, "opacity": 100 }
        ]
    },
    {
        "name": "Foreground to Background",
        "gradientForm": "customStops",
        "interpolation": 4096,
        "colors":
        [
            { "location": 0, "midpoint": 50, "type": "foregroundColor" },
            { "location": 4096, "midpoint": 50, "type": "backgroundColor" }
        ],
        "transparency":
        [
            { "location": 0, "midpoint": 50, "opacity": 100 },
            { "location": 4096, "midpoint": 50, "opacity": 100 }
        ]
    },
    {
        "name": "Magenta Noise",
        "gradientForm": "colorNoise",
        "randomSeed": 345807450,
        "showTransparency": false,
        "vectorColor": true,
        "smoothness": 1024,
        "colorSpace": "RGBColor",
        "minimum": [ 0, 18, 25, 0 ],
        "maximum": [ 100, 60, 73, 100 ]
    }
]

Gradients displayed in the Preset Manager, after being loaded from the generated gradients file:

Preset Manager Gradients Dialog (Mac OS X)

Requirements

This script can be used in Adobe Photoshop CS3 or later. It has been successfully tested in CS4 on Mac OS X, but should be platform agnostic.

This Software is copyright © 2011-2015 by Michel MARIANI.

License

This Software is licensed under the GNU General Public License (GPL) v3.

Download

Download Zip File

Installation

Download the Zip file and unzip it.

Move the script to the Presets/Scripts folder in the default preset location of the Adobe Photoshop application. On next launch, the script will appear in the File>Automate submenu.