-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathWorkingWithText.py
More file actions
41 lines (34 loc) · 1.03 KB
/
Copy pathWorkingWithText.py
File metadata and controls
41 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Text layer with size, position, and RGB colour (macOS).
from appscript import k
from ps_connect import photoshop
ps = photoshop()
strt_ruler = ps.settings.ruler_units()
strt_type = ps.settings.type_units()
ps.settings.ruler_units.set(k.inch_units)
try:
ps.settings.type_units.set(k.points_units)
except Exception:
pass
ps.display_dialogs.set(k.never)
doc = ps.make(
new=k.document,
with_properties={k.width: 7, k.height: 5, k.resolution: 72},
)
layer = doc.make(new=k.art_layer, with_properties={k.kind: k.text_layer})
text = layer.text_object
text.contents.set("Hello, World!")
text.position.set([0.75, 0.75])
text.size.set(36)
# Colour as RGB record
try:
text.stroke_color.set({k.class_: k.RGB_color_, k.red: 225, k.green: 0, k.blue: 0})
except Exception:
try:
text.color.set({k.class_: k.RGB_color_, k.red: 225, k.green: 0, k.blue: 0})
except Exception as exc:
print("color note:", exc)
ps.settings.ruler_units.set(strt_ruler)
try:
ps.settings.type_units.set(strt_type)
except Exception:
pass