Skip to content

Adjustments

create_color_layer(color, layer, **kwargs)

Create a solid color adjustment layer. @param color: Color to use for the layer. @param layer: ArtLayer or LayerSet to make active. @keyword clipped (bool): Whether to apply as a clipping mask to the nearest layer, defaults to True. @return: The new solid color adjustment layer.

Source code in src/helpers/adjustments.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def create_color_layer(color: SolidColor, layer: Union[ArtLayer, LayerSet, None], **kwargs) -> ArtLayer:
    """
    Create a solid color adjustment layer.
    @param color: Color to use for the layer.
    @param layer: ArtLayer or LayerSet to make active.
    @keyword clipped (bool): Whether to apply as a clipping mask to the nearest layer, defaults to True.
    @return: The new solid color adjustment layer.
    """
    if layer:
        app.activeDocument.activeLayer = layer
    desc1 = ActionDescriptor()
    ref1 = ActionReference()
    desc2 = ActionDescriptor()
    desc3 = ActionDescriptor()
    ref1.putClass(sID("contentLayer"))
    desc1.putReference(sID("target"), ref1)
    desc2.putBoolean(sID("group"), kwargs.get('clipped', True))
    desc2.putEnumerated(sID("color"), sID("color"), sID("blue"))
    apply_color(desc3, color)
    desc2.putObject(sID("type"), sID("solidColorLayer"), desc3)
    desc1.putObject(sID("using"), sID("contentLayer"), desc2)
    app.executeAction(sID("make"), desc1, NO_DIALOG)
    return app.activeDocument.activeLayer

create_gradient_layer(colors, layer, **kwargs)

Create a gradient adjustment layer. @param colors: List of gradient color dicts. @param layer: ArtLayer or LayerSet to make active. @keyword clipped (bool): Whether to apply as a clipping mask to the nearest layer, defaults to True. @keyword rotation (Union[int, float]): Rotation to apply to the gradient, defaults to 90. @keyword scale (Union[int, float]): Scale to apply to the gradient, defaults to 100. @return: The new gradient adjustment layer.

Source code in src/helpers/adjustments.py
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def create_gradient_layer(colors: list[dict], layer: Union[ArtLayer, LayerSet, None], **kwargs) -> ArtLayer:
    """
    Create a gradient adjustment layer.
    @param colors: List of gradient color dicts.
    @param layer: ArtLayer or LayerSet to make active.
    @keyword clipped (bool): Whether to apply as a clipping mask to the nearest layer, defaults to True.
    @keyword rotation (Union[int, float]): Rotation to apply to the gradient, defaults to 90.
    @keyword scale (Union[int, float]): Scale to apply to the gradient, defaults to 100.
    @return: The new gradient adjustment layer.
    """
    if layer:
        app.activeDocument.activeLayer = layer
    desc1 = ActionDescriptor()
    ref1 = ActionReference()
    desc2 = ActionDescriptor()
    desc3 = ActionDescriptor()
    desc4 = ActionDescriptor()
    color_list = ActionList()
    list2 = ActionList()
    desc9 = ActionDescriptor()
    desc10 = ActionDescriptor()
    ref1.putClass(sID("contentLayer"))
    desc1.putReference(sID("target"),  ref1)
    desc2.putBoolean(sID("group"), kwargs.get('clipped', True))
    desc3.putEnumerated(
        sID("gradientsInterpolationMethod"),
        sID("gradientInterpolationMethodType"),
        sID("perceptual")
    )
    desc3.putUnitDouble(sID("angle"), sID("angleUnit"), kwargs.get('rotation', 0))
    desc3.putEnumerated(sID("type"), sID("gradientType"), sID("linear"))
    desc3.putUnitDouble(sID("scale"), sID("percentUnit"), kwargs.get('scale', 100))
    desc4.putEnumerated(sID("gradientForm"), sID("gradientForm"), sID("customStops"))
    desc4.putDouble(sID("interfaceIconFrameDimmed"),  4096)
    for c in colors:
        add_color_to_gradient(
            color_list,
            get_color(c.get('color', rgb_black())),
            int(c.get('location', 0)),
            int(c.get('midpoint', 50))
        )
    desc4.putList(sID("colors"),  color_list)
    desc9.putUnitDouble(sID("opacity"), sID("percentUnit"),  100)
    desc9.putInteger(sID("location"),  0)
    desc9.putInteger(sID("midpoint"),  50)
    list2.putObject(sID("transferSpec"),  desc9)
    desc10.putUnitDouble(sID("opacity"), sID("percentUnit"),  100)
    desc10.putInteger(sID("location"),  4096)
    desc10.putInteger(sID("midpoint"),  50)
    list2.putObject(sID("transferSpec"),  desc10)
    desc4.putList(sID("transparency"),  list2)
    desc3.putObject(sID("gradient"), sID("gradientClassEvent"),  desc4)
    desc2.putObject(sID("type"), sID("gradientLayer"),  desc3)
    desc1.putObject(sID("using"), sID("contentLayer"),  desc2)
    app.executeAction(sID("make"), desc1,  NO_DIALOG)
    return app.activeDocument.activeLayer

create_vibrant_saturation(vibrancy, saturation)

Experimental scoot action to add vibrancy and saturation. @param vibrancy: Vibrancy level integer @param saturation: Saturation level integer

Source code in src/helpers/adjustments.py
20
21
22
23
24
25
26
27
28
29
30
def create_vibrant_saturation(vibrancy: int, saturation: int) -> None:
    """
    Experimental scoot action to add vibrancy and saturation.
    @param vibrancy: Vibrancy level integer
    @param saturation: Saturation level integer
    """
    # dialogMode (Have dialog popup?)
    desc232 = ActionDescriptor()
    desc232.putInteger(sID("vibrance"), vibrancy)
    desc232.putInteger(sID("saturation"), saturation)
    app.executeAction(sID("vibrance"), desc232, NO_DIALOG)