Skip to content

Commit

Permalink
Clear up
Browse files Browse the repository at this point in the history
  • Loading branch information
hao.long committed Feb 23, 2020
1 parent 7e7e314 commit 64db849
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 112 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: "conf.py"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
Expand Down
42 changes: 17 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,24 @@ Hello World

```python

from photoshop import Application
from photoshop import JPEGSaveOptions
from photoshop import SolidColor
from photoshop import LayerKind

app = Application()
import photoshop as ps
app = ps.Application()
doc = app.documents.add()
new_doc = doc.artLayers.add()
text_color = SolidColor()
text_color.rgb.red = 225
text_color = ps.SolidColor()
text_color.rgb.green = 255
text_color.rgb.blue = 0
new_text_layer = new_doc
new_text_layer.kind = LayerKind.BRIGHTNESSCONTRAST
new_text_layer.textItem.contents = "Hello, World!"
new_text_layer.kind = ps.LayerKind.TextLayer
new_text_layer.textItem.contents = 'Hello, World!'
new_text_layer.textItem.position = [160, 167]
new_text_layer.textItem.size = 40
new_text_layer.textItem.color = text_color
options = JPEGSaveOptions()
options.quality = 10
options = ps.JPEGSaveOptions(quality=5)
# # save to jpg
jpg = 'd:/hello_world.jpg'
doc.saveAs(jpg, options, as_copy=True)
app.eval_javascript('alert("save to jpg: {}")'.format(jpg))
doc.saveAs(jpg, options, asCopy=True)
app.doJavaScript(f'alert("save to jpg: {jpg}")')

```

Create thumbnail
Expand All @@ -69,10 +63,9 @@ Create thumbnail

```python

from photoshop import Application
from photoshop import JPEGSaveOptions
import photoshop as ps

app = Application()
app = ps.Application()
active_document = app.activeDocument
orig_name = active_document.name
width_str = active_document.width
Expand All @@ -82,8 +75,7 @@ thumb_width = int(width_str / index)
thumb_height = int(height_str / index)
thumb_doc = active_document.duplicate('{}_tumb'.format(orig_name))
thumb_doc.resizeImage(thumb_width, thumb_height)
o = JPEGSaveOptions()
o.quality = 10
o = ps.JPEGSaveOptions(quality=10)
thumb_doc.saveAs('c:/thumb.jpg', o, as_copy=True)
thumb_doc.close()

Expand All @@ -94,15 +86,15 @@ Run javascript

```python

from photoshop import Application
import photoshop as ps

app = Application()
app = ps.Application()
jsx = r"""
var doc = app.activeDocument;
var orig_name = doc.name;
alert(orig_name);
"""
app.eval_javascript(jsx)
app.doJavaScript(jsx)

```

Expand All @@ -111,9 +103,9 @@ Open .psd file

```python

from photoshop import Application
import photoshop as ps

app = Application()
app = ps.Application()
app.load("your/psd/or/psb/file_path.psd")

```
Expand Down
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/installation.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/usage.doctree
Binary file not shown.
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
1 change: 0 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ Or you can install via pip.
.. code-block:: console
$ pip install photoshop_python_api
40 changes: 20 additions & 20 deletions docs/src/photoshop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ photoshop.application module
:undoc-members:
:show-inheritance:

photoshop.art\_layer module
---------------------------
photoshop.artlayer module
-------------------------

.. automodule:: photoshop.art_layer
.. automodule:: photoshop.artlayer
:members:
:undoc-members:
:show-inheritance:

photoshop.art\_layers module
----------------------------
photoshop.artlayers module
--------------------------

.. automodule:: photoshop.art_layers
.. automodule:: photoshop.artlayers
:members:
:undoc-members:
:show-inheritance:
Expand Down Expand Up @@ -100,6 +100,14 @@ photoshop.documents module
:undoc-members:
:show-inheritance:

photoshop.enumerations module
-----------------------------

.. automodule:: photoshop.enumerations
:members:
:undoc-members:
:show-inheritance:

photoshop.errors module
-----------------------

Expand All @@ -116,18 +124,18 @@ photoshop.layer module
:undoc-members:
:show-inheritance:

photoshop.layerSets module
--------------------------
photoshop.layerSet module
-------------------------

.. automodule:: photoshop.layerSets
.. automodule:: photoshop.layerSet
:members:
:undoc-members:
:show-inheritance:

photoshop.layer\_kind module
----------------------------
photoshop.layerSets module
--------------------------

.. automodule:: photoshop.layer_kind
.. automodule:: photoshop.layerSets
:members:
:undoc-members:
:show-inheritance:
Expand Down Expand Up @@ -180,14 +188,6 @@ photoshop.text\_item module
:undoc-members:
:show-inheritance:

photoshop.units module
----------------------

.. automodule:: photoshop.units
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------
Expand Down
68 changes: 4 additions & 64 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,22 @@ Usage
Hello World
-----------

.. code-block:: python
from photoshop import Application
from photoshop import JPEGSaveOptions
from photoshop import SolidColor
from photoshop import LayerKind
app = Application()
doc = app.documents.add()
new_doc = doc.artLayers.add()
text_color = SolidColor()
text_color.rgb.red = 225
text_color.rgb.green = 255
text_color.rgb.blue = 0
new_text_layer = new_doc
new_text_layer.kind = LayerKind.BRIGHTNESSCONTRAST
new_text_layer.textItem.contents = "Hello, World!"
new_text_layer.textItem.position = [160, 167]
new_text_layer.textItem.size = 40
new_text_layer.textItem.color = text_color
options = JPEGSaveOptions()
options.quality = 10
# # save to jpg
jpg = 'd:/hello_world.jpg'
doc.saveAs(jpg, options, as_copy=True)
app.eval_javascript('alert("save to jpg: {}")'.format(jpg))
.. literalinclude:: ../examples/hello_world.py


Create thumbnail
----------------


.. code-block:: python
from photoshop import Application
from photoshop import JPEGSaveOptions
app = Application()
active_document = app.activeDocument
orig_name = active_document.name
width_str = active_document.width
height_str = active_document.height
index = width_str / 1280
thumb_width = int(width_str / index)
thumb_height = int(height_str / index)
thumb_doc = active_document.duplicate('{}_tumb'.format(orig_name))
thumb_doc.resizeImage(thumb_width, thumb_height)
o = JPEGSaveOptions()
o.quality = 10
thumb_doc.saveAs('c:/thumb.jpg', o, as_copy=True)
thumb_doc.close()
.. literalinclude:: ../examples/create_thumbnail.py

Run javascript
--------------

.. code-block:: python
from photoshop import Application
.. literalinclude:: ../examples/eval_javascript.py

app = Application()
jsx = r"""
var doc = app.activeDocument;
var orig_name = doc.name;
alert(orig_name);
"""
app.eval_javascript(jsx)


Open .psd file
--------------

.. code-block:: python
from photoshop import Application
app = Application()
app.load("your/psd/or/psb/file_path.psd")
.. literalinclude:: ../examples/open_psd.py
1 change: 0 additions & 1 deletion examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

def hello_world():
app = ps.Application()
print(app.foregroundColor.rgb)
doc = app.documents.add()
new_doc = doc.artLayers.add()
text_color = ps.SolidColor()
Expand Down
4 changes: 4 additions & 0 deletions examples/open_psd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import photoshop as ps

app = ps.Application()
app.load("your/psd/or/psb/file_path.psd")
2 changes: 1 addition & 1 deletion test/manual_test_artlayer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from photoshop.art_layer import ArtLayer
from photoshop.artlayer import ArtLayer


def hello_world():
Expand Down

0 comments on commit 64db849

Please sign in to comment.