Skip to content

Commit 7d1b13a

Browse files
committed
Merge remote-tracking branch 'upstream/main' into action_manager_module_integration
2 parents 202df61 + e93d290 commit 7d1b13a

14 files changed

+223
-45
lines changed

.all-contributorsrc

+9
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@
145145
"contributions": [
146146
"bug"
147147
]
148+
},
149+
{
150+
"login": "Alyxion",
151+
"name": "Michael Ikemann",
152+
"avatar_url": "https://avatars.githubusercontent.com/u/33489959?v=4",
153+
"profile": "http://www.linkedin.com/in/michael-ikemann",
154+
"contributions": [
155+
"bug"
156+
]
148157
}
149158
],
150159
"skipCi": true

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ result/
2020
# Coverage output
2121
.coverage
2222
/venv/
23+
venv_python
2324

2425
# Docs
2526
docs_src/_build/

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## v0.20.1 (2022-11-28)
2+
3+
### Refactor
4+
5+
- **action_descriptor**: Fix type hints for doubles
6+
7+
## v0.20.0 (2022-11-26)
8+
9+
### Feat
10+
11+
- add a new option for create batch
12+
13+
## v0.19.7 (2022-11-14)
14+
15+
### Fix
16+
17+
- **deps**: update dependency wheel to ^0.38.0
18+
119
## v0.19.6 (2022-11-06)
220

321
### Refactor

README.md

+25-22
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
28-
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
28+
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors-)
2929
<!-- ALL-CONTRIBUTORS-BADGE:END -->
3030
</p>
3131

@@ -122,27 +122,30 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
122122
<!-- prettier-ignore-start -->
123123
<!-- markdownlint-disable -->
124124
<table>
125-
<tr>
126-
<td align="center"><a href="https://github.com/loonghao"><img src="https://avatars1.githubusercontent.com/u/13111745?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hal</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=loonghao" title="Code">💻</a></td>
127-
<td align="center"><a href="https://github.com/voodraizer"><img src="https://avatars0.githubusercontent.com/u/1332729?v=4?s=100" width="100px;" alt=""/><br /><sub><b>voodraizer</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Avoodraizer" title="Bug reports">🐛</a></td>
128-
<td align="center"><a href="https://github.com/brunosly"><img src="https://avatars2.githubusercontent.com/u/4326547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>brunosly</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Abrunosly" title="Bug reports">🐛</a></td>
129-
<td align="center"><a href="https://github.com/tubi-carrillo"><img src="https://avatars3.githubusercontent.com/u/33004093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tubi</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Atubi-carrillo" title="Bug reports">🐛</a></td>
130-
<td align="center"><a href="https://github.com/wjxiehaixin"><img src="https://avatars0.githubusercontent.com/u/48039822?v=4?s=100" width="100px;" alt=""/><br /><sub><b>wjxiehaixin</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Awjxiehaixin" title="Bug reports">🐛</a></td>
131-
<td align="center"><a href="http://it.econline.net"><img src="https://avatars0.githubusercontent.com/u/993544?v=4?s=100" width="100px;" alt=""/><br /><sub><b>罗马钟</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Aenzozhong" title="Bug reports">🐛</a></td>
132-
<td align="center"><a href="https://github.com/ClementHector"><img src="https://avatars.githubusercontent.com/u/7068597?v=4?s=100" width="100px;" alt=""/><br /><sub><b>clement</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3AClementHector" title="Bug reports">🐛</a></td>
133-
</tr>
134-
<tr>
135-
<td align="center"><a href="https://github.com/krevlinmen"><img src="https://avatars.githubusercontent.com/u/56278440?v=4?s=100" width="100px;" alt=""/><br /><sub><b>krevlinmen</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Akrevlinmen" title="Bug reports">🐛</a></td>
136-
<td align="center"><a href="https://github.com/SThomasN"><img src="https://avatars.githubusercontent.com/u/63218023?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thomas</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3ASThomasN" title="Bug reports">🐛</a></td>
137-
<td align="center"><a href="https://github.com/CaptainCsaba"><img src="https://avatars.githubusercontent.com/u/59013751?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CaptainCsaba</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3ACaptainCsaba" title="Bug reports">🐛</a></td>
138-
<td align="center"><a href="https://ilharper.vbox.moe"><img src="https://avatars.githubusercontent.com/u/20179549?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Il Harper</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=Afanyiyu" title="Code">💻</a></td>
139-
<td align="center"><a href="https://github.com/blunderedbishop"><img src="https://avatars.githubusercontent.com/u/56189376?v=4?s=100" width="100px;" alt=""/><br /><sub><b>blunderedbishop</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Ablunderedbishop" title="Bug reports">🐛</a></td>
140-
<td align="center"><a href="https://github.com/MrTeferi"><img src="https://avatars.githubusercontent.com/u/92750180?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MrTeferi</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=MrTeferi" title="Code">💻</a></td>
141-
<td align="center"><a href="https://github.com/damienchambe"><img src="https://avatars.githubusercontent.com/u/42462209?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Damien Chambe</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=damienchambe" title="Code">💻</a></td>
142-
</tr>
143-
<tr>
144-
<td align="center"><a href="https://github.com/be42day"><img src="https://avatars.githubusercontent.com/u/20614168?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ehsan Akbari Tabar</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Abe42day" title="Bug reports">🐛</a></td>
145-
</tr>
125+
<tbody>
126+
<tr>
127+
<td align="center"><a href="https://github.com/loonghao"><img src="https://avatars1.githubusercontent.com/u/13111745?v=4?s=100" width="100px;" alt="Hal"/><br /><sub><b>Hal</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=loonghao" title="Code">💻</a></td>
128+
<td align="center"><a href="https://github.com/voodraizer"><img src="https://avatars0.githubusercontent.com/u/1332729?v=4?s=100" width="100px;" alt="voodraizer"/><br /><sub><b>voodraizer</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Avoodraizer" title="Bug reports">🐛</a></td>
129+
<td align="center"><a href="https://github.com/brunosly"><img src="https://avatars2.githubusercontent.com/u/4326547?v=4?s=100" width="100px;" alt="brunosly"/><br /><sub><b>brunosly</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Abrunosly" title="Bug reports">🐛</a></td>
130+
<td align="center"><a href="https://github.com/tubi-carrillo"><img src="https://avatars3.githubusercontent.com/u/33004093?v=4?s=100" width="100px;" alt="tubi"/><br /><sub><b>tubi</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Atubi-carrillo" title="Bug reports">🐛</a></td>
131+
<td align="center"><a href="https://github.com/wjxiehaixin"><img src="https://avatars0.githubusercontent.com/u/48039822?v=4?s=100" width="100px;" alt="wjxiehaixin"/><br /><sub><b>wjxiehaixin</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Awjxiehaixin" title="Bug reports">🐛</a></td>
132+
<td align="center"><a href="http://it.econline.net"><img src="https://avatars0.githubusercontent.com/u/993544?v=4?s=100" width="100px;" alt="罗马钟"/><br /><sub><b>罗马钟</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Aenzozhong" title="Bug reports">🐛</a></td>
133+
<td align="center"><a href="https://github.com/ClementHector"><img src="https://avatars.githubusercontent.com/u/7068597?v=4?s=100" width="100px;" alt="clement"/><br /><sub><b>clement</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3AClementHector" title="Bug reports">🐛</a></td>
134+
</tr>
135+
<tr>
136+
<td align="center"><a href="https://github.com/krevlinmen"><img src="https://avatars.githubusercontent.com/u/56278440?v=4?s=100" width="100px;" alt="krevlinmen"/><br /><sub><b>krevlinmen</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Akrevlinmen" title="Bug reports">🐛</a></td>
137+
<td align="center"><a href="https://github.com/SThomasN"><img src="https://avatars.githubusercontent.com/u/63218023?v=4?s=100" width="100px;" alt="Thomas"/><br /><sub><b>Thomas</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3ASThomasN" title="Bug reports">🐛</a></td>
138+
<td align="center"><a href="https://github.com/CaptainCsaba"><img src="https://avatars.githubusercontent.com/u/59013751?v=4?s=100" width="100px;" alt="CaptainCsaba"/><br /><sub><b>CaptainCsaba</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3ACaptainCsaba" title="Bug reports">🐛</a></td>
139+
<td align="center"><a href="https://ilharper.vbox.moe"><img src="https://avatars.githubusercontent.com/u/20179549?v=4?s=100" width="100px;" alt="Il Harper"/><br /><sub><b>Il Harper</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=Afanyiyu" title="Code">💻</a></td>
140+
<td align="center"><a href="https://github.com/blunderedbishop"><img src="https://avatars.githubusercontent.com/u/56189376?v=4?s=100" width="100px;" alt="blunderedbishop"/><br /><sub><b>blunderedbishop</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Ablunderedbishop" title="Bug reports">🐛</a></td>
141+
<td align="center"><a href="https://github.com/MrTeferi"><img src="https://avatars.githubusercontent.com/u/92750180?v=4?s=100" width="100px;" alt="MrTeferi"/><br /><sub><b>MrTeferi</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=MrTeferi" title="Code">💻</a></td>
142+
<td align="center"><a href="https://github.com/damienchambe"><img src="https://avatars.githubusercontent.com/u/42462209?v=4?s=100" width="100px;" alt="Damien Chambe"/><br /><sub><b>Damien Chambe</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/commits?author=damienchambe" title="Code">💻</a></td>
143+
</tr>
144+
<tr>
145+
<td align="center"><a href="https://github.com/be42day"><img src="https://avatars.githubusercontent.com/u/20614168?v=4?s=100" width="100px;" alt="Ehsan Akbari Tabar"/><br /><sub><b>Ehsan Akbari Tabar</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3Abe42day" title="Bug reports">🐛</a></td>
146+
<td align="center"><a href="http://www.linkedin.com/in/michael-ikemann"><img src="https://avatars.githubusercontent.com/u/33489959?v=4?s=100" width="100px;" alt="Michael Ikemann"/><br /><sub><b>Michael Ikemann</b></sub></a><br /><a href="https://github.com/loonghao/photoshop-python-api/issues?q=author%3AAlyxion" title="Bug reports">🐛</a></td>
147+
</tr>
148+
</tbody>
146149
</table>
147150

148151
<!-- markdownlint-restore -->

examples/run_batch.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Import built-in modules
2+
import os
3+
4+
# Import local modules
5+
from photoshop import Session
6+
7+
8+
root = "your/images/root"
9+
files = []
10+
for name in os.listdir(root):
11+
files.append(os.path.join(root, name))
12+
with Session() as api:
13+
options = api.BatchOptions()
14+
options.destination = 3
15+
options.destinationFolder = "c:\\test"
16+
api.app.batch(files=files, actionName="Quadrant Colors", actionSet="Default Actions", options=options)

photoshop/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.19.6"
1+
__version__ = "0.20.1"

photoshop/api/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Python API for Photoshop."""
2-
32
# Import local modules
43
from photoshop.api import constants
54
from photoshop.api._actionmanager_type_binder import ActionDescriptor
65
from photoshop.api._actionmanager_type_binder import ActionList
76
from photoshop.api._actionmanager_type_binder import ActionReference
87
from photoshop.api.application import Application
8+
from photoshop.api.batch_options import BatchOptions
99
from photoshop.api.colors import CMYKColor
1010
from photoshop.api.colors import GrayColor
1111
from photoshop.api.colors import HSBColor
@@ -35,6 +35,7 @@
3535
"ActionReference",
3636
"ActionList",
3737
"Application",
38+
"BatchOptions",
3839
"constants",
3940
"enumerations",
4041
"PhotoshopPythonAPIError",

photoshop/api/action_descriptor.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def getUnitDoubleType(self, key: int) -> int:
151151
"""Gets the unit type of a key of type UnitDouble."""
152152
return self.app.getUnitDoubleType(key)
153153

154-
def getUnitDoubleValue(self, key: int) -> float:
155-
"""Gets the value of a key of type UnitDouble."""
154+
def getUnitDoubleValue(self, key: int) -> int:
155+
"""Gets the unit type of a key of type UnitDouble."""
156156
return self.app.getUnitDoubleValue(key)
157157

158158
def putBoolean(self, key: int, value: bool):
@@ -171,7 +171,7 @@ def putData(self, key: int, value: str):
171171
except BaseException:
172172
pass
173173

174-
def putDouble(self, key: int, value: float):
174+
def putDouble(self, key: int, value: int):
175175
"""Sets the value for a key whose type is double."""
176176
self.app.putDouble(key, value)
177177

@@ -213,6 +213,12 @@ def putString(self, key: int, value: str):
213213
"""Sets the value for a key whose type is string."""
214214
self.app.putString(key, value)
215215

216-
def putUnitDouble(self, key: int, classID: int, value: float):
217-
"""Sets the value for a key whose type is a unit value formatted as a double."""
218-
self.app.putUnitDouble(key, classID, value)
216+
def putUnitDouble(self, key: int, unit_id: int, value: int):
217+
"""Sets the value for a key whose type is a unit value formatted as
218+
double."""
219+
self.app.putUnitDouble(key, unit_id, value)
220+
221+
def toStream(self) -> str:
222+
"""Gets the entire descriptor as as stream of bytes,
223+
for writing to disk."""
224+
return self.app.toSteadm()

photoshop/api/application.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
app.documents.add(800, 600, 72, "docRef")
1111
1212
"""
13-
1413
# Import built-in modules
1514
import os
1615
from pathlib import Path
@@ -260,13 +259,13 @@ def windowsFileTypes(self):
260259
return self.app.windowsFileTypes
261260

262261
# Methods.
263-
def batch(self, *args, **kwargs):
262+
def batch(self, files, actionName, actionSet, options):
264263
"""Runs the batch automation routine.
265264
266265
Similar to the **File** > **Automate** > **Batch** command.
267266
268267
"""
269-
self.app.bath(*args, **kwargs)
268+
self.app.batch(files, actionName, actionSet, options)
270269

271270
def beep(self):
272271
"""Causes a "beep" sound."""

photoshop/api/batch_options.py

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# https://theiviaxx.github.io/photoshop-docs/Photoshop/BatchOptions.html
2+
# Import local modules
3+
from photoshop.api._core import Photoshop
4+
5+
6+
class BatchOptions(Photoshop):
7+
object_name = "BatchOptions"
8+
9+
def __init__(self):
10+
super().__init__()
11+
12+
@property
13+
def destination(self):
14+
"""The type of destination for the processed files."""
15+
return self.app.destination
16+
17+
@destination.setter
18+
def destination(self, value):
19+
self.app.destination = value
20+
21+
@property
22+
def destinationFolder(self):
23+
"""The folder location for the processed files. Valid only when ‘destination’ = folder."""
24+
return self.app.destinationFolder
25+
26+
@destinationFolder.setter
27+
def destinationFolder(self, path):
28+
self.app.destinationFolder = path
29+
30+
@property
31+
def errorFile(self):
32+
"""The file in which to log errors encountered.
33+
To display errors on the screen and stop batch processing when errors occur, leave blank."""
34+
return self.app.errorFile
35+
36+
@errorFile.setter
37+
def errorFile(self, file_path):
38+
self.app.errorFile = file_path
39+
40+
@property
41+
def fileNaming(self) -> list:
42+
"""A list of file naming options. Maximum: 6."""
43+
return self.app.fileNaming
44+
45+
@fileNaming.setter
46+
def fileNaming(self, file_naming: list):
47+
self.app.fileNaming = file_naming
48+
49+
@property
50+
def macintoshCompatible(self) -> bool:
51+
"""If true, the final file names are Macintosh compatible."""
52+
return self.app.macintoshCompatible
53+
54+
@macintoshCompatible.setter
55+
def macintoshCompatible(self, value: bool):
56+
self.app.macintoshCompatible = value
57+
58+
@property
59+
def overrideOpen(self) -> bool:
60+
"""If true, overrides action open commands."""
61+
return self.app.overrideOpen
62+
63+
@overrideOpen.setter
64+
def overrideOpen(self, value: bool):
65+
self.app.overrideOpen = value
66+
67+
@property
68+
def overrideSave(self) -> bool:
69+
"""If true, overrides save as action steps with the specified destination."""
70+
return self.app.overrideSave
71+
72+
@overrideSave.setter
73+
def overrideSave(self, value: bool):
74+
self.app.overrideSave = value
75+
76+
@property
77+
def startingSerial(self) -> int:
78+
"""The starting serial number to use in naming files."""
79+
return self.app.startingSerial
80+
81+
@startingSerial.setter
82+
def startingSerial(self, value: int):
83+
self.app.startingSerial = value
84+
85+
@property
86+
def suppressOpen(self) -> bool:
87+
"""If true, suppresses file open options dialogs."""
88+
return self.app.suppressOpen
89+
90+
@suppressOpen.setter
91+
def suppressOpen(self, value: bool):
92+
self.app.suppressOpen = value
93+
94+
@property
95+
def suppressProfile(self) -> bool:
96+
"""If true, suppresses color profile warnings."""
97+
return self.app.suppressProfile
98+
99+
@suppressProfile.setter
100+
def suppressProfile(self, value: bool):
101+
self.app.suppressProfile = value
102+
103+
@property
104+
def unixCompatible(self) -> bool:
105+
"""If true, the final file names are Unix compatible."""
106+
return self.app.unixCompatible
107+
108+
@unixCompatible.setter
109+
def unixCompatible(self, value: bool):
110+
self.app.unixCompatible = value
111+
112+
@property
113+
def windowsCompatible(self) -> bool:
114+
"""If true, the final file names are Windows compatible."""
115+
return self.app.windowsCompatible
116+
117+
@windowsCompatible.setter
118+
def windowsCompatible(self, value: bool):
119+
self.app.windowsCompatible = value

photoshop/session.py

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from photoshop.api import ActionReference
3636
from photoshop.api import Application
3737
from photoshop.api import BMPSaveOptions
38+
from photoshop.api import BatchOptions
3839
from photoshop.api import CMYKColor
3940
from photoshop.api import EPSSaveOptions
4041
from photoshop.api import EventID
@@ -128,6 +129,7 @@ def __init__(
128129
self.EventID = EventID
129130
self.SolidColor = SolidColor
130131
self.TextItem = TextItem
132+
self.BatchOptions = BatchOptions
131133

132134
# The save options.
133135
self.GIFSaveOptions = GIFSaveOptions

0 commit comments

Comments
 (0)