Assistance Needed for Saving Photoshop Document to Use with AI APIs

Hello community,

I am relatively new to Photoshop plugin development, and I’m currently working on a project that involves integrating AI APIs. Specifically, I am aiming to save a Photoshop document as an image (JPEG format) so that I can feed it into a web API and receive responses.

Despite consulting the documentation and searching online, I have not been able to find up-to-date and relevant information on achieving this task. If anyone has experience or insights into this, I would greatly appreciate your guidance.

Any help, tips, or resources you can provide would be immensely valuable. Thank you in advance for your assistance!

Have you checked out this part of the documentation? It refers to the different options to save a Photoshop document, e.g. as JPG. You could for instance save it into the plugin’s data folder temporarily and send it over the network.

I’ve seen this section of documentation before, but I couldn’t use it. Perhaps it’s outdated or I’m not proficient enough in JavaScript to utilize it effectively (as I primarily use Python)

Gotcha. I might suggest then brushing up on just basic Javascript programming. You can find any number of great resources online, and people have posted links to good resources here in the forum in the past, which should be easy to find.

As for the task at hand, the particular documentation I referred to should be pretty up to date and there’s nothing magical about it. The documentation really just goes over the methods and properties of the DOM, i.e. the different objects you get access to via the API. Since you use Python I’m sure you’re familiar with object oriented programming.

I would recommend looking at some of the UXP example scripts to familiarize yourself with how to get a simple plugin set up. There are also example scripts dealing with network communication, which you might find helpful. As for saving a Photoshop document: You really just call saveAs on the active document.

const app = require('photoshop').app;
const constants = require('photoshop').constants;

// The currently active document from the Photoshop object
const currentDocument = app.activeDocument;

// Get a location to save to:
let entry = await require('uxp').storage.localFileSystem.getFileForSaving("target.jpg");
document.saveAs.jpg(entry);

(This is practically copied from the first few lines of the documentation).

I’d suggest you give it a try and report back if you run into issues. :slight_smile:

Hi! I apologize for the delay - things have been quite hectic on my end, which meant I couldn’t dedicate the proper time to this project.

It seems the issue might be with UXP not installing correctly on my PC, rather than the code itself (yours actually looks really similar to what I’ve tested before!). I’ve tried reinstalling it, but unfortunately, it still doesn’t seem to cooperate.

Would you be available to lend a hand and help on this project? I’d really appreciate it! We could definitely hop on Discord or another platform that works best for you.

Let me know what you think!

It sounds like you have some homework to do. I would suggest trying to get one of the many UXP sample projects to run. If you are struggling with that or can’t get UXP to install I would recommend opening another thread asking about that specifically and try to get some help with that.

That said, in order for people to properly help you they will need more information, e.g. steps or code you tried. Simply saying something doesn’t work is not enough to adequately guide you. I would also say, people will be much more inclined to spend the time helping you, if they feel like you respect their time and put in some work on your end. :slight_smile:

Good luck!

Hi there, thanks so much for taking the time to help me out! I just realized that I might have explained things poorly, and I apologize if anything I said came across as disrespectful.

The issue with Adobe is a bit complex in my country, and it’s not something I (or anyone else here) can easily solve on our own.

Regardless, I truly appreciate your willingness to offer support, and I wanted to make sure you know that.

No need to apologize. :slight_smile: To clarify and avoid any misunderstanding, I never suggested you were saying anything that was disrespectful. In my answer I talked about respecting people’s time. There’s a difference. To be more specific, a lot of us here in the forum aren’t directly affiliated with Adobe. We’re merely fellow users or engineers who share advice and hence volunteer our time.

It’s absolutely no shame to ask for help! But it makes it easier to help you if you give proper details on what things you’ve tried on your own and what exactly the issues are that you’re trying to solve.