-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add new example * Add new option to save tga * Remove _layer.py * Clear up and add more enumerations * Clear up * Update package version * implement doc channels * Clear up Co-authored-by: hao.long <[email protected]>
- Loading branch information
Showing
6 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""A examples to show you how to operation active document channels.""" | ||
|
||
from photoshop import Session | ||
|
||
with Session() as ps: | ||
doc = ps.active_document | ||
print(len(doc.channels)) | ||
doc.channels.add() | ||
doc.channels.removeAll() | ||
channel = doc.channels.getByName("Red") | ||
print(channel.name) | ||
channel.remove() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from photoshop._core import Photoshop | ||
|
||
|
||
# pylint: disable=too-many-public-methods | ||
class Channel(Photoshop): | ||
def __init__(self, parent): | ||
super().__init__(parent=parent) | ||
|
||
@property | ||
def color(self): | ||
return self.app.color | ||
|
||
@color.setter | ||
def color(self, value): | ||
self.app.color = value | ||
|
||
@property | ||
def histogram(self): | ||
return self.app.histogram | ||
|
||
@histogram.setter | ||
def histogram(self, value): | ||
self.app.histogram = value | ||
|
||
@property | ||
def kind(self): | ||
return self.app.kind | ||
|
||
@kind.setter | ||
def kind(self, value): | ||
self.app.kind = value | ||
|
||
@property | ||
def opacity(self): | ||
return self.app.opacity | ||
|
||
@opacity.setter | ||
def opacity(self, value): | ||
self.app.opacity = value | ||
|
||
@property | ||
def visible(self): | ||
return self.app.visible | ||
|
||
@visible.setter | ||
def visible(self, value): | ||
self.app.visible = value | ||
|
||
@property | ||
def name(self): | ||
return self.app.name | ||
|
||
def duplicate(self, targetDocument=None): | ||
self.app.duplicate(targetDocument) | ||
|
||
def merge(self): | ||
self.app.merge() | ||
|
||
def remove(self): | ||
channel = f'app.activeDocument.channels.getByName("{self.name}")' | ||
self.eval_javascript(f"{channel}.remove()") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from photoshop._core import Photoshop | ||
from photoshop._channel import Channel | ||
from photoshop.errors import PhotoshopPythonAPIError | ||
|
||
|
||
# pylint: disable=too-many-public-methods | ||
class Channels(Photoshop): | ||
def __init__(self, parent): | ||
super().__init__(parent=parent) | ||
|
||
@property | ||
def _channels(self): | ||
return list(self.app) | ||
|
||
def __len__(self): | ||
return self.length | ||
|
||
def __iter__(self): | ||
for layer in self.app: | ||
yield layer | ||
|
||
def __getitem__(self, item): | ||
return self.app[item] | ||
|
||
@property | ||
def length(self): | ||
return len(self._channels) | ||
|
||
def add(self): | ||
self.app.add() | ||
|
||
def removeAll(self): | ||
self.app.removeAll() | ||
|
||
def getByName(self, name): | ||
for channel in self._channels: | ||
if channel.name == name: | ||
return Channel(channel) | ||
raise PhotoshopPythonAPIError("Could not find a channel named " | ||
f'"{name}"') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters