Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into action_manager_modu…
Browse files Browse the repository at this point in the history
…le_integration
  • Loading branch information
TsXor committed Dec 3, 2022
2 parents 202df61 + e93d290 commit 7d1b13a
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 45 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@
"contributions": [
"bug"
]
},
{
"login": "Alyxion",
"name": "Michael Ikemann",
"avatar_url": "https://avatars.githubusercontent.com/u/33489959?v=4",
"profile": "http://www.linkedin.com/in/michael-ikemann",
"contributions": [
"bug"
]
}
],
"skipCi": true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ result/
# Coverage output
.coverage
/venv/
venv_python

# Docs
docs_src/_build/
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## v0.20.1 (2022-11-28)

### Refactor

- **action_descriptor**: Fix type hints for doubles

## v0.20.0 (2022-11-26)

### Feat

- add a new option for create batch

## v0.19.7 (2022-11-14)

### Fix

- **deps**: update dependency wheel to ^0.38.0

## v0.19.6 (2022-11-06)

### Refactor
Expand Down
47 changes: 25 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


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

Expand Down Expand Up @@ -122,27 +122,30 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
<tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
<tr>
<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>
</tr>
<tbody>
<tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
<tr>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</tr>
<tr>
<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>
<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>
</tr>
</tbody>
</table>

<!-- markdownlint-restore -->
Expand Down
16 changes: 16 additions & 0 deletions examples/run_batch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Import built-in modules
import os

# Import local modules
from photoshop import Session


root = "your/images/root"
files = []
for name in os.listdir(root):
files.append(os.path.join(root, name))
with Session() as api:
options = api.BatchOptions()
options.destination = 3
options.destinationFolder = "c:\\test"
api.app.batch(files=files, actionName="Quadrant Colors", actionSet="Default Actions", options=options)
2 changes: 1 addition & 1 deletion photoshop/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.19.6"
__version__ = "0.20.1"
3 changes: 2 additions & 1 deletion photoshop/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Python API for Photoshop."""

# Import local modules
from photoshop.api import constants
from photoshop.api._actionmanager_type_binder import ActionDescriptor
from photoshop.api._actionmanager_type_binder import ActionList
from photoshop.api._actionmanager_type_binder import ActionReference
from photoshop.api.application import Application
from photoshop.api.batch_options import BatchOptions
from photoshop.api.colors import CMYKColor
from photoshop.api.colors import GrayColor
from photoshop.api.colors import HSBColor
Expand Down Expand Up @@ -35,6 +35,7 @@
"ActionReference",
"ActionList",
"Application",
"BatchOptions",
"constants",
"enumerations",
"PhotoshopPythonAPIError",
Expand Down
18 changes: 12 additions & 6 deletions photoshop/api/action_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def getUnitDoubleType(self, key: int) -> int:
"""Gets the unit type of a key of type UnitDouble."""
return self.app.getUnitDoubleType(key)

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

def putBoolean(self, key: int, value: bool):
Expand All @@ -171,7 +171,7 @@ def putData(self, key: int, value: str):
except BaseException:
pass

def putDouble(self, key: int, value: float):
def putDouble(self, key: int, value: int):
"""Sets the value for a key whose type is double."""
self.app.putDouble(key, value)

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

def putUnitDouble(self, key: int, classID: int, value: float):
"""Sets the value for a key whose type is a unit value formatted as a double."""
self.app.putUnitDouble(key, classID, value)
def putUnitDouble(self, key: int, unit_id: int, value: int):
"""Sets the value for a key whose type is a unit value formatted as
double."""
self.app.putUnitDouble(key, unit_id, value)

def toStream(self) -> str:
"""Gets the entire descriptor as as stream of bytes,
for writing to disk."""
return self.app.toSteadm()
5 changes: 2 additions & 3 deletions photoshop/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
app.documents.add(800, 600, 72, "docRef")
"""

# Import built-in modules
import os
from pathlib import Path
Expand Down Expand Up @@ -260,13 +259,13 @@ def windowsFileTypes(self):
return self.app.windowsFileTypes

# Methods.
def batch(self, *args, **kwargs):
def batch(self, files, actionName, actionSet, options):
"""Runs the batch automation routine.
Similar to the **File** > **Automate** > **Batch** command.
"""
self.app.bath(*args, **kwargs)
self.app.batch(files, actionName, actionSet, options)

def beep(self):
"""Causes a "beep" sound."""
Expand Down
119 changes: 119 additions & 0 deletions photoshop/api/batch_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# https://theiviaxx.github.io/photoshop-docs/Photoshop/BatchOptions.html
# Import local modules
from photoshop.api._core import Photoshop


class BatchOptions(Photoshop):
object_name = "BatchOptions"

def __init__(self):
super().__init__()

@property
def destination(self):
"""The type of destination for the processed files."""
return self.app.destination

@destination.setter
def destination(self, value):
self.app.destination = value

@property
def destinationFolder(self):
"""The folder location for the processed files. Valid only when ‘destination’ = folder."""
return self.app.destinationFolder

@destinationFolder.setter
def destinationFolder(self, path):
self.app.destinationFolder = path

@property
def errorFile(self):
"""The file in which to log errors encountered.
To display errors on the screen and stop batch processing when errors occur, leave blank."""
return self.app.errorFile

@errorFile.setter
def errorFile(self, file_path):
self.app.errorFile = file_path

@property
def fileNaming(self) -> list:
"""A list of file naming options. Maximum: 6."""
return self.app.fileNaming

@fileNaming.setter
def fileNaming(self, file_naming: list):
self.app.fileNaming = file_naming

@property
def macintoshCompatible(self) -> bool:
"""If true, the final file names are Macintosh compatible."""
return self.app.macintoshCompatible

@macintoshCompatible.setter
def macintoshCompatible(self, value: bool):
self.app.macintoshCompatible = value

@property
def overrideOpen(self) -> bool:
"""If true, overrides action open commands."""
return self.app.overrideOpen

@overrideOpen.setter
def overrideOpen(self, value: bool):
self.app.overrideOpen = value

@property
def overrideSave(self) -> bool:
"""If true, overrides save as action steps with the specified destination."""
return self.app.overrideSave

@overrideSave.setter
def overrideSave(self, value: bool):
self.app.overrideSave = value

@property
def startingSerial(self) -> int:
"""The starting serial number to use in naming files."""
return self.app.startingSerial

@startingSerial.setter
def startingSerial(self, value: int):
self.app.startingSerial = value

@property
def suppressOpen(self) -> bool:
"""If true, suppresses file open options dialogs."""
return self.app.suppressOpen

@suppressOpen.setter
def suppressOpen(self, value: bool):
self.app.suppressOpen = value

@property
def suppressProfile(self) -> bool:
"""If true, suppresses color profile warnings."""
return self.app.suppressProfile

@suppressProfile.setter
def suppressProfile(self, value: bool):
self.app.suppressProfile = value

@property
def unixCompatible(self) -> bool:
"""If true, the final file names are Unix compatible."""
return self.app.unixCompatible

@unixCompatible.setter
def unixCompatible(self, value: bool):
self.app.unixCompatible = value

@property
def windowsCompatible(self) -> bool:
"""If true, the final file names are Windows compatible."""
return self.app.windowsCompatible

@windowsCompatible.setter
def windowsCompatible(self, value: bool):
self.app.windowsCompatible = value
2 changes: 2 additions & 0 deletions photoshop/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from photoshop.api import ActionReference
from photoshop.api import Application
from photoshop.api import BMPSaveOptions
from photoshop.api import BatchOptions
from photoshop.api import CMYKColor
from photoshop.api import EPSSaveOptions
from photoshop.api import EventID
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(
self.EventID = EventID
self.SolidColor = SolidColor
self.TextItem = TextItem
self.BatchOptions = BatchOptions

# The save options.
self.GIFSaveOptions = GIFSaveOptions
Expand Down
Loading

0 comments on commit 7d1b13a

Please sign in to comment.