|
8 | 8 | import photoshop.api.action_manager as am
|
9 | 9 |
|
10 | 10 |
|
11 |
| -with Session(action="new_document") as ps: |
12 |
| - # replace it with your own path here |
13 |
| - import_dict = {"_classID": None, "null": pathlib.Path("your/image/path")} |
| 11 | +def importfile(app, path: pathlib.WindowsPath, position: (float, float), size: (float, float)): # noqa |
| 12 | + px, py = position |
| 13 | + sx, sy = size |
| 14 | + import_dict = { |
| 15 | + "null": path, |
| 16 | + "freeTransformCenterState": am.Enumerated(type="quadCenterState", value="QCSAverage"), |
| 17 | + "offset": { |
| 18 | + "horizontal": am.UnitDouble(unit="distanceUnit", double=px), |
| 19 | + "vertical": am.UnitDouble(unit="distanceUnit", double=py), |
| 20 | + "_classID": "offset", |
| 21 | + }, |
| 22 | + "width": am.UnitDouble(unit="percentUnit", double=sx), |
| 23 | + "height": am.UnitDouble(unit="percentUnit", double=sy), |
| 24 | + "_classID": None, |
| 25 | + } |
14 | 26 | import_desc = ps.ActionDescriptor.load(import_dict)
|
15 |
| - ps.app.executeAction(am.str2id("Plc "), import_desc) |
16 |
| - # length of charID should always be 4, if not, pad with spaces |
| 27 | + app.executeAction(am.str2id("placeEvent"), import_desc) |
| 28 | + |
| 29 | + |
| 30 | +with Session(action="new_document") as ps: |
| 31 | + importfile(ps.app, pathlib.Path("your/image/path"), (-100, 456), (4470, 4463)) |
0 commit comments