{"id":13585884,"url":"https://github.com/lohriialo/photoshop-scripting-python","last_synced_at":"2025-04-07T10:32:13.544Z","repository":{"id":143585081,"uuid":"120317897","full_name":"lohriialo/photoshop-scripting-python","owner":"lohriialo","description":"Scripting in Photoshop is used to automate a wide variety of repetitive task or as complex as an entire new feature","archived":false,"fork":false,"pushed_at":"2023-07-10T03:48:07.000Z","size":45133,"stargazers_count":491,"open_issues_count":8,"forks_count":94,"subscribers_count":25,"default_branch":"main","last_synced_at":"2024-11-06T03:44:02.416Z","etag":null,"topics":["adobe","illustrator","illustrator-scripts","indesign","indesign-scripts","photoshop","photoshop-javascript","photoshop-plugin","photoshop-script","python","scripting"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lohriialo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-05T14:46:38.000Z","updated_at":"2024-11-05T00:58:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"a6be1bb7-1632-4ec4-bf12-c62c7fa3a8e2","html_url":"https://github.com/lohriialo/photoshop-scripting-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohriialo%2Fphotoshop-scripting-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohriialo%2Fphotoshop-scripting-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohriialo%2Fphotoshop-scripting-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lohriialo%2Fphotoshop-scripting-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lohriialo","download_url":"https://codeload.github.com/lohriialo/photoshop-scripting-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247637031,"owners_count":20971048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adobe","illustrator","illustrator-scripts","indesign","indesign-scripts","photoshop","photoshop-javascript","photoshop-plugin","photoshop-script","python","scripting"],"created_at":"2024-08-01T15:05:12.210Z","updated_at":"2025-04-07T10:32:11.469Z","avatar_url":"https://github.com/lohriialo.png","language":"Python","readme":"# Photoshop Scripting in Python\n![](https://i.imgur.com/8wOWcPX.png \"Photoshop Python\")\n\nScripting in Photoshop is used to automate repetitive tasks and are often used as a creative tool to streamline tasks that might be too\ntime consuming to do manually. For example, you could write a script to generate a number of localized\nversions of a particular image or to gather information about the various color profiles used by a collection\nof images.\n\n# Photoshop COM \u0026 DOM\nPhotoshop can be scripted through COM(Component Object Model). Its DOM(Document Object Model) is the same when accessing it through either its own JavaScript engine or Python or any other scripting language it supports. The Photoshop DOM consists of a hierarchical representation of the Photoshop application, the documents used in it, and the components of the documents. The DOM allows you to programmatically access and manipulate the document and its components. For example, through the DOM, you can create\na new document, add a layer to an existing document, or change the background color of a layer. Most of\nthe functionality available through the Photoshop user interface is available through the DOM.\n\n# But why Python?\nPhotoshop scripting officially supports JavaScript, AppleScript \u0026 VBScript. However, Scripting in Python is also fairly easy if not easier if you're already comfortable with Python. You may have already heard that Python is gaining in popularity, but did you know it’s now the most popular introductory programming language in U.S. universities? Python is also cross platform just like JavaScript is and lately becoming one of the fastest growing programming language according to StackOverflow [as of 2017](https://stackoverflow.blog/2017/09/06/incredible-growth-python) / [as of 2019](https://insights.stackoverflow.com/survey/2019#key-results)\n\nPython is easy to use, powerful, and versatile, making it a great choice for beginners and experts alike. Python’s readability makes it a great first programming language - it allows you to think like a programmer and not waste time understanding the mysterious syntax that other programming languages can require.\n\n# Getting Started\nPython allows you to access COM and it's DOM with the help of a Python extensions like  \"pypiwin32\" or \"comtypes\". Install these modules and you're ready to start scripting Photoshop in Python\n\n* `pip install pypiwin32` or `pip install comtypes`\n\n# Hello World!\n```python\nfrom win32com.client import Dispatch\n\napp = Dispatch(\"Photoshop.Application\")\ndoc = app.Documents.Add(320, 240)\nlayerRef = doc.ArtLayers.Add()\n\npsTextLayer = 2  # from enum PsLayerKind\nlayerRef.Kind = psTextLayer\n\ntextItem = layerRef.TextItem\ntextItem.Contents = \"HELLO WORLD!\"\ntextItem.Position = (120, 120)\n```\n# How to inspect scripting object properties?\nThere's not a straight forward way, you need to read the documentation to understand what properties/attributes are available for a scripting object, or possibly a COM browser. For example, I've extracted the Python scripting object reference for Photoshop CC 2018 at [api_reference](https://github.com/lohriialo/photoshop-scripting-python/tree/master/api_reference)\n\n# GUI tool example\nSee [`gui_tool`](https://github.com/lohriialo/photoshop-scripting-python/tree/master/gui_tool_example) for an example of how you can use Photoshop Scripting to develop your own tool/utilities\n\n# Scripting on Mac?\nYes, scripting on Mac is also possible, see [mac_scripting](https://github.com/lohriialo/photoshop-scripting-python/tree/master/mac_scripting) for more details\n\n# Photoshop Scripting Resources\n* [Photoshop Scripting Documentation](https://www.adobe.com/devnet/photoshop/scripting.html)\n* [Photoshop Scripting Developer Forum](https://forums.adobe.com/community/photoshop/photoshop_scripting)\n* [Photoshop Scripting API Reference](https://www.adobe.com/devnet/photoshop/scripting.html)\n* [Photoshop Scripting Tutorials](https://www.youtube.com/playlist?list=PLUEniN8BpU8-Qmjyv3zyWaNvDYwJOJZ4m)\n\n# Also see\n* [InDesign Scripting in Python](https://github.com/lohriialo/indesign-scripting-python)\n* [Illustrator Scripting in Python](https://github.com/lohriialo/illustrator-scripting-python)\n\n# Contribution\nIf you've written a useful Photoshop Python script and wants to share with the world, please create a new issue with the file as an attachment to the issue.\n\nWhen you submit a script, please try to include the following information at the start of your script\n```python\n# script_file_name.py\n\n# Created: 1st January 2019\n__author__ = 'Your Name or Original Author Name'\n__version__ = '1.0'\n\n\"\"\"\nA short description of what the script does\n\"\"\"\n\n\"\"\"\nInstructions on how to use the script, if any\n\"\"\"\n\n```\n* Go to  [photoshop-scripting-python/issues/new](https://github.com/lohriialo/photoshop-scripting-python/issues/new)\n* Add title  as `Useful Script`\n* Drag \u0026 drop your .py script file into the description area\n* Click `Submit new issue`\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flohriialo%2Fphotoshop-scripting-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flohriialo%2Fphotoshop-scripting-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flohriialo%2Fphotoshop-scripting-python/lists"}