Skip to main content

Python API for Photoshop.

Project description

logo

python version PyPI version Downloads Status Downloads License pypi format Chat on Discird Maintenance Bump version pages-build-deployment Documentation Status

All Contributors

Python API for Photoshop.

The example above was created with Photoshop Python API. Check it out at https://loonghao.github.io/photoshop-python-api/examples.

Has been tested and used Photoshop version:

Photoshop Version Supported
2022
2021
2020
cc2019
cc2018
cc2017

Installing

You can install via pip.

pip install photoshop_python_api

Since it uses COM (Component Object Model) connect Photoshop, it can be used in any DCC software with a python interpreter.

Hello World

import photoshop.api as ps
app = ps.Application()
doc = app.documents.add()
new_doc = doc.artLayers.add()
text_color = ps.SolidColor()
text_color.rgb.red = 0
text_color.rgb.green = 255
text_color.rgb.blue = 0
new_text_layer = new_doc
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 = ps.JPEGSaveOptions(quality=5)
# # save to jpg
jpg = 'd:/hello_world.jpg'
doc.saveAs(jpg, options, asCopy=True)
app.doJavaScript(f'alert("save to jpg: {jpg}")')

demo

Photoshop Session

Use it as context.

from photoshop import Session


with Session(action="new_document") as ps:
    doc = ps.active_document
    text_color = ps.SolidColor()
    text_color.rgb.green = 255
    new_text_layer = doc.artLayers.add()
    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 = ps.JPEGSaveOptions(quality=5)
    jpg = 'd:/hello_world.jpg'
    doc.saveAs(jpg, options, asCopy=True)
    ps.app.doJavaScript(f'alert("save to jpg: {jpg}")')

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Hal

💻

voodraizer

🐛

brunosly

🐛

tubi

🐛

wjxiehaixin

🐛

罗马钟

🐛

clement

🐛

krevlinmen

🐛

Thomas

🐛

CaptainCsaba

🐛

Il Harper

💻

blunderedbishop

🐛

MrTeferi

💻

Damien Chambe

💻

Ehsan Akbari Tabar

🐛

This project follows the all-contributors specification. Contributions of any kind are welcome!

Repobeats analytics

Repobeats analytics

how to get Photoshop program ID

Get-ChildItem "HKLM:\SOFTWARE\Classes" | 
  ?{ ($_.PSChildName -match "^[a-z]+\.[a-z]+(\.\d+)?$") -and ($_.GetSubKeyNames() -contains "CLSID") } | 
  ?{ $_.PSChildName -match "Photoshop.Application" } | ft PSChildName

get_program_id

How to get a list of COM objects from the registry

Useful links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

photoshop_python_api-0.20.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

photoshop_python_api-0.20.0-py3-none-any.whl (66.1 kB view details)

Uploaded Python 3

File details

Details for the file photoshop_python_api-0.20.0.tar.gz.

File metadata

  • Download URL: photoshop_python_api-0.20.0.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.11.0 Linux/5.15.0-1023-azure

File hashes

Hashes for photoshop_python_api-0.20.0.tar.gz
Algorithm Hash digest
SHA256 e5af9da3ac0e939a02a6f11b868ee8fe790bfa09f6d5c545119daad350dd15c8
MD5 ccaab08709b3400ba7f90066b44e8280
BLAKE2b-256 4e044fdea04f402d5cd848a13699665be172ffbbe7a6a39d68e5c2f690d2e3e8

See more details on using hashes here.

Provenance

File details

Details for the file photoshop_python_api-0.20.0-py3-none-any.whl.

File metadata

File hashes

Hashes for photoshop_python_api-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b84b8fa658e25a0689cd557a7e803a66f72b900e05d59d2764407a69bab79fe
MD5 162b08d105ae6ed924aa661dde121498
BLAKE2b-256 27c87929c6655ff53139d04a88e81021446a365c6cfd11f98573309189153584

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page