How to Use Codex with Photoshop: A Practical Guide
In this article
You cannot connect OpenAI Codex directly to Adobe Photoshop as a live plugin, but you can use Codex to write scripts and actions that automate Photoshop tasks. The practical workflow is: describe what you want in plain language to Codex, have it generate a JavaScript (.jsx) or ExtendScript file, then run that file inside Photoshop via File > Scripts > Browse. This works on Photoshop desktop (Windows and macOS); Photoshop on iPad does not support running custom scripts. You need a Codex-enabled tool (such as the OpenAI API, ChatGPT with Codex access, or a Codex-integrated editor), a desktop Photoshop installation, and basic ability to save and locate files.
What You'll Need
- A desktop computer running Photoshop (Creative Cloud subscription or a licensed older version). Scripting is not available in Photoshop on iPad or in Photoshop Express.
- Access to a Codex-capable interface: the OpenAI API with a Codex model, ChatGPT with Codex enabled (if available on your plan), or an editor extension that uses Codex.
- A plain text editor (Notepad on Windows, TextEdit on macOS, or VS Code) to save the generated code as a .jsx file.
- Basic familiarity with Photoshop's File > Scripts menu and the concept of layers and documents.
- Optional: Adobe's ExtendScript Toolkit or VS Code with an ExtendScript extension for debugging, though Photoshop's built-in script errors are usually enough.
Menu labels can differ slightly by Photoshop version, operating system, and region. The steps below assume Photoshop 2020 or later on Windows or macOS.
Step-by-Step
- Define the task precisely. Write down exactly what you want Photoshop to do, including document state, layer names, colors, sizes, and output format. For example: "On the active document, create a new layer named 'Watermark', add the text 'DRAFT' at 48pt, rotate it 45 degrees, set opacity to 30%, and export a PNG copy to the Desktop." Vague requests produce scripts that fail or do the wrong thing.
- Ask Codex for a Photoshop script. Use only documented Photoshop DOM methods, check that a document is open, and wrap the main logic in a try/catch that alerts the error message. Codex will return JavaScript code. If it returns Python or another language, ask specifically for ExtendScript for Photoshop.
- Review the generated code before running it. Look for anything that deletes layers, closes documents without saving, or writes outside your intended folder. Codex can hallucinate method names; if you see something like
app.activeDocument.mergeAllLayers()that you do not recognize, ask Codex to verify it against the Photoshop scripting reference or to use a safer alternative. Never run a script you have not read. - Save the code as a .jsx file. Open your text editor, paste the code, and save it with a .jsx extension (for example,
watermark.jsx) in a folder you can find easily, such as Documents or the Desktop. Make sure the editor does not add .txt to the filename; on Windows, choose "All Files" in the Save As dialog and type the name with .jsx. - Open Photoshop and load a test document. Use a copy of a real file, not your only original. Scripts can modify or close documents, so a disposable test file protects your work.
- Run the script. In Photoshop, go to File > Scripts > Browse, select your .jsx file, and click Open. Photoshop executes the script immediately. If the script is designed to show a dialog, it appears now; otherwise, watch the document for the expected change.
- Check the result and iterate. If the script errors, Photoshop shows an alert with a line number and message. Copy that message back into Codex and ask it to fix the specific error, then save and run again. Repeat until the script behaves correctly on your test file.
- Save the working script for reuse. Once it works, keep the .jsx file in a dedicated scripts folder. You can run it again via File > Scripts > Browse, or place it in Photoshop's Presets/Scripts folder so it appears directly in the File > Scripts menu after a restart. Only do this with scripts you trust.
Common Mistakes
- Asking for a plugin instead of a script. Codex cannot install itself into Photoshop. Requests for a "Codex plugin" lead nowhere; ask for ExtendScript or a .jsx file.
- Running untested code on original files. Always test on a copy. A script with a wrong layer reference can delete or flatten content.
- Using vague prompts. "Make my photo look better" produces unusable code. Specify layer names, dimensions, colors, and file paths.
- Saving as .txt. Photoshop will not run a .txt file from File > Scripts > Browse. Confirm the extension is .jsx.
- Ignoring version differences. Codex may generate code for an older Photoshop DOM. If a method fails, tell Codex your Photoshop version and ask for a compatible approach.
- Forgetting to check for an open document. Scripts that assume a document is open will error if none is. Ask Codex to include a check and a clear alert.
Tips
- Ask Codex to add comments to each block so you can understand and edit the script later.
- Request a try/catch wrapper with
alert(e.message)so errors are readable instead of silent failures. - For repetitive batch work, ask Codex to loop over files in a folder, but test on two or three files first and confirm the output folder is correct.
- Keep prompts specific about units: pixels vs. percent, points vs. pixels for text, and RGB vs. CMYK.
- If you need the same effect often, ask Codex to turn the script into a function you can call with different parameters at the top of the file.
- Use Photoshop's Actions panel for simple recorded steps; use Codex-generated scripts when you need logic, conditionals, or file handling that Actions cannot do.
Troubleshooting
If the script does nothing, first confirm you selected the right file and that a document is open. If Photoshop shows an error alert, read the message and line number, then paste both into Codex with the original prompt and ask for a corrected version. If the error mentions an undefined method, the generated code likely used a function that does not exist in your Photoshop version; ask Codex to rewrite using only documented DOM methods and state your version.
If the script runs but produces the wrong result, compare the output to your written task description. Often the prompt was ambiguous, such as "resize the image" without a target size. Refine the prompt with exact values and rerun on a fresh copy of the test file.
If Photoshop becomes unresponsive, wait a few seconds; some scripts process large files slowly. If it stays frozen, force-quit Photoshop and reopen it. Unsaved changes in open documents will be lost, so save before running unfamiliar scripts. If the script modified and saved a file incorrectly, restore from a backup or the original copy you set aside.
If File > Scripts > Browse is greyed out, no document may be open, or your Photoshop installation may be incomplete; try opening a document first. If the menu is missing entirely, you may be using Photoshop on a device or version that does not support scripts, such as Photoshop on iPad.
Frequently Asked Questions
Can Codex control Photoshop directly in real time?
No. Codex generates code; it does not connect to Photoshop as a live controller. You run the generated script manually inside Photoshop.
Does this work with Photoshop on iPad?
No. Photoshop on iPad does not support running custom .jsx scripts. Use a desktop version of Photoshop for scripting.
What language should I ask Codex to write?
Ask for ExtendScript, saved as a .jsx file. That is the scripting language Photoshop desktop runs through File > Scripts.
Is it safe to run Codex-generated scripts?
Only if you read the code first and test on a copy of your file. Codex can produce incorrect or destructive commands, so review for delete, close, and save operations before running.
Can I make the script appear in the File > Scripts menu permanently?
Yes, place the .jsx file in Photoshop's Presets/Scripts folder and restart Photoshop. Only do this with scripts you have reviewed and trust.
Why does my script fail with an error about a missing method?
The generated code likely used a method that does not exist in your Photoshop version. Tell Codex your exact Photoshop version and ask it to rewrite using only documented Photoshop DOM methods.