|
2 | 2 | from photoshop import Session
|
3 | 3 | import photoshop.api.action_manager as am
|
4 | 4 |
|
| 5 | + |
5 | 6 | with Session() as ps:
|
6 | 7 | app = ps.app
|
7 | 8 | for index, x in enumerate(range(50)):
|
8 | 9 | # Execute an existing action from action palette.
|
9 | 10 | exec_dict = {
|
10 |
| - '_classID':None, |
11 |
| - 'null':[ |
12 |
| - '!ref', |
13 |
| - am.ReferenceKey(desiredclass='action', value='Sepia Toning (layer)'), |
14 |
| - am.ReferenceKey(desiredclass='actionSet', value='Default Actions') |
15 |
| - ] |
| 11 | + "_classID": None, |
| 12 | + "null": [ |
| 13 | + "!ref", |
| 14 | + am.ReferenceKey(desiredclass="action", value="Sepia Toning (layer)"), |
| 15 | + am.ReferenceKey(desiredclass="actionSet", value="Default Actions"), |
| 16 | + ], |
16 | 17 | }
|
17 | 18 | exec_desc = ps.ActionDescriptor.load(exec_dict)
|
18 |
| - app.executeAction(am.str2id('Ply '), exec_desc, ps.DialogModes.DisplayNoDialogs) |
| 19 | + app.executeAction(am.str2id("Ply "), exec_desc, ps.DialogModes.DisplayNoDialogs) |
19 | 20 |
|
20 | 21 | # Create solid color fill layer.
|
21 | 22 | filledlayer_dict = {
|
22 |
| - '_classID':None, |
23 |
| - 'null':[ |
24 |
| - '!ref', |
25 |
| - am.ReferenceKey(desiredclass='contentLayer',value=None) |
26 |
| - ], |
27 |
| - 'using':{ |
28 |
| - '_classID':'contentLayer', |
29 |
| - 'type':{ |
30 |
| - '_classID':'solidColorLayer', |
31 |
| - 'color':{ |
32 |
| - '_classID':'RGBColor', |
33 |
| - 'red':index, |
34 |
| - 'grain':index, |
35 |
| - 'blue':index |
36 |
| - } |
37 |
| - } |
38 |
| - } |
| 23 | + "_classID": None, |
| 24 | + "null": ["!ref", am.ReferenceKey(desiredclass="contentLayer", value=None)], |
| 25 | + "using": { |
| 26 | + "_classID": "contentLayer", |
| 27 | + "type": { |
| 28 | + "_classID": "solidColorLayer", |
| 29 | + "color": {"_classID": "RGBColor", "red": index, "grain": index, "blue": index}, |
| 30 | + }, |
| 31 | + }, |
39 | 32 | }
|
40 | 33 | filledlayer_desc = ps.ActionDescriptor.load(filledlayer_dict)
|
41 |
| - app.executeAction(am.str2id('Mk '), filledlayer_desc, ps.DialogModes.DisplayNoDialogs) |
| 34 | + app.executeAction(am.str2id("Mk "), filledlayer_desc, ps.DialogModes.DisplayNoDialogs) |
42 | 35 |
|
43 | 36 | # Select mask.
|
44 | 37 | selectmask_dict = {
|
45 |
| - '_classID':None, |
46 |
| - 'null':[ |
47 |
| - '!ref', |
48 |
| - am.ReferenceKey(desiredclass='channel', value=am.Enumerated(type='channel',value='mask')) |
| 38 | + "_classID": None, |
| 39 | + "null": [ |
| 40 | + "!ref", |
| 41 | + am.ReferenceKey(desiredclass="channel", value=am.Enumerated(type="channel", value="mask")), |
49 | 42 | ],
|
50 |
| - 'makeVisible':False |
| 43 | + "makeVisible": False, |
51 | 44 | }
|
52 | 45 | selectmask_desc = ps.ActionDescriptor.load(selectmask_dict)
|
53 |
| - app.executeAction(am.str2id('slct'), selectmask_desc, ps.DialogModes.DisplayNoDialogs) |
| 46 | + app.executeAction(am.str2id("slct"), selectmask_desc, ps.DialogModes.DisplayNoDialogs) |
54 | 47 |
|
55 | 48 | app.activeDocument.activeLayer.invert()
|
0 commit comments