Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 92899c8

Browse filesBrowse files
committed
style(examples): processed with black and isort
1 parent b9a8a0b commit 92899c8
Copy full SHA for 92899c8
Expand file treeCollapse file tree

7 files changed

+53
-62
lines changed

‎examples/apply_crystallize_filter_action.py

Copy file name to clipboardExpand all lines: examples/apply_crystallize_filter_action.py
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@
3131
active_document.activeLayer = active_document.layerSets.item(len(nLayerSets)).artLayers.item(len(nArtLayers))
3232

3333
def applyCrystallize(cellSize):
34-
filter_dict = {
35-
'_classID':None,
36-
'ClSz':cellSize
37-
}
34+
filter_dict = {"_classID": None, "ClSz": cellSize}
3835
filter_desc = ps.ActionDescriptor.load(filter_dict)
3936
ps.app.executeAction(am.str2id("Crst"), filter_desc)
4037

‎examples/convert_smartobject_to_layer.py

Copy file name to clipboardExpand all lines: examples/convert_smartobject_to_layer.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Convert Smart object to artLayer."""
22

33
# Import builtin modules
4+
# Import built-in modules
45
from textwrap import dedent
56

67
# Import local modules
@@ -10,10 +11,12 @@
1011

1112
# example 1
1213
with Session() as ps:
13-
js = dedent("""
14+
js = dedent(
15+
"""
1416
var idplacedLayerConvertToLayers = stringIDToTypeID( "placedLayerConvertToLayers" );
1517
executeAction( idplacedLayerConvertToLayers, undefined, DialogModes.NO );
16-
""")
18+
"""
19+
)
1720
ps.app.doJavaScript(js)
1821

1922
# example 2

‎examples/emboss_action.py

Copy file name to clipboardExpand all lines: examples/emboss_action.py
+24-31Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,47 @@
22
from photoshop import Session
33
import photoshop.api.action_manager as am
44

5+
56
with Session() as ps:
67
app = ps.app
78
for index, x in enumerate(range(50)):
89
# Execute an existing action from action palette.
910
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+
],
1617
}
1718
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)
1920

2021
# Create solid color fill layer.
2122
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+
},
3932
}
4033
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)
4235

4336
# Select mask.
4437
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")),
4942
],
50-
'makeVisible':False
43+
"makeVisible": False,
5144
}
5245
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)
5447

5548
app.activeDocument.activeLayer.invert()

‎examples/import_image_as_layer.py

Copy file name to clipboard
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
"""Import a image as a artLayer."""
22

3+
# Import built-in modules
4+
import pathlib
5+
36
# Import local modules
47
from photoshop import Session
5-
import pathlib
68

79

810
with Session(action="new_document") as ps:
9-
import_dict = {
10-
'_classID':None,
11-
'null':pathlib.Path("your/image/path") # replace it with your own path here
12-
}
11+
import_dict = {"_classID": None, "null": pathlib.Path("your/image/path")} # replace it with your own path here
1312
import_desc = ps.ActionDescriptor.load(import_dict)
1413
ps.app.executeAction(am.str2id("Plc "), import_desc) # `Plc` need one space in here.

‎examples/replace_images.py

Copy file name to clipboardExpand all lines: examples/replace_images.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Replace the image of the current active layer with a new image."""
22

33
# Import builtin modules
4+
# Import built-in modules
45
import pathlib
56

67
# Import third-party modules
@@ -17,10 +18,7 @@
1718
active_layer = ps.active_document.activeLayer
1819
bounds = active_layer.bounds
1920
print(f"current layer {active_layer.name}: {bounds}")
20-
input_dict = {
21-
'_classID':None,
22-
'null':pathlib.Path(PSD_FILE["red_100x200.png"])
23-
}
21+
input_dict = {"_classID": None, "null": pathlib.Path(PSD_FILE["red_100x200.png"])}
2422
input_desc = ps.ActionDescriptor.load(input_dict)
2523
ps.app.executeAction(am.str2id("placedLayerReplaceContents"), input_desc)
2624

‎examples/session_smart_sharpen.py

Copy file name to clipboardExpand all lines: examples/session_smart_sharpen.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
def SmartSharpen(inAmount, inRadius, inNoise):
2222
ss_dict = {
23-
'_classID':None,
24-
'presetKindType':am.Enumerated(type='presetKindType', value='presetKindCustom'),
25-
'amount':am.UnitDouble(unit='radius', double=inAmount),
26-
'radius':am.UnitDouble(unit='pixelsUnit', double=inRadius),
27-
'noiseReduction':am.UnitDouble(unit='percentUnit', double=inNoise),
28-
'blur':am.Enumerated(type='blurType', value='gaussianBlur')
23+
"_classID": None,
24+
"presetKindType": am.Enumerated(type="presetKindType", value="presetKindCustom"),
25+
"amount": am.UnitDouble(unit="radius", double=inAmount),
26+
"radius": am.UnitDouble(unit="pixelsUnit", double=inRadius),
27+
"noiseReduction": am.UnitDouble(unit="percentUnit", double=inNoise),
28+
"blur": am.Enumerated(type="blurType", value="gaussianBlur"),
2929
}
3030
ss_desc = ps.ActionDescriptor.load(ss_dict)
31-
app.ExecuteAction(am.str2id('smartSharpen'), ss_desc)
31+
app.ExecuteAction(am.str2id("smartSharpen"), ss_desc)
3232

33-
SmartSharpen(300, 2.0, 20)
33+
SmartSharpen(300, 2.0, 20)

‎examples/smart_sharpen.py

Copy file name to clipboardExpand all lines: examples/smart_sharpen.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727

2828
def SmartSharpen(inAmount, inRadius, inNoise):
2929
ss_dict = {
30-
'_classID':None,
31-
'presetKindType':am.Enumerated(type='presetKindType', value='presetKindCustom'),
32-
'amount':am.UnitDouble(unit='radius', double=inAmount),
33-
'radius':am.UnitDouble(unit='pixelsUnit', double=inRadius),
34-
'noiseReduction':am.UnitDouble(unit='percentUnit', double=inNoise),
35-
'blur':am.Enumerated(type='blurType', value='gaussianBlur')
30+
"_classID": None,
31+
"presetKindType": am.Enumerated(type="presetKindType", value="presetKindCustom"),
32+
"amount": am.UnitDouble(unit="radius", double=inAmount),
33+
"radius": am.UnitDouble(unit="pixelsUnit", double=inRadius),
34+
"noiseReduction": am.UnitDouble(unit="percentUnit", double=inNoise),
35+
"blur": am.Enumerated(type="blurType", value="gaussianBlur"),
3636
}
3737
ss_desc = ps.ActionDescriptor.load(ss_dict)
38-
app.ExecuteAction(am.str2id('smartSharpen'), ss_desc)
38+
app.ExecuteAction(am.str2id("smartSharpen"), ss_desc)
3939

40-
SmartSharpen(300, 2.0, 20)
40+
41+
SmartSharpen(300, 2.0, 20)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.