Skip to main content
Alex0721
Participant
March 4, 2026
Question

UXP how to export artboard or layer as jpeg

  • March 4, 2026
  • 0 replies
  • 11 views

Hi everyone,

in a Photoshop 2026 UXP plugin I want to export an artboard (or layer) as an jpeg image. Same function as right clicking an artboard or layer and selecting “Export As” choosing JPG with quality 6.

I am using Photoshop 2026 27.4.0 on OSX with M1 CPU. UXP 9.2.0 and UXP Developer Tools 2.2.1

I just found a method to export a whole document using document.saveAs.jpeg() method. But I do not want to export the whole document, just a few artboards inside it.
I tried duplicating the document and using document.crop() method on the copy. But the crop method doesn’t do anything, the document with and height are the same after crop(). See here:

/*
Non working example of using document.crop()
*/
await core.executeAsModal(async () => {
const document = app.activeDocument;
console.log(`Document size before crop: ${document.width} x ${document.height}`);
const res = await document.crop({top: -61, bottom: 660, left: 8753, right: 9934});
console.log(`Document size after crop: ${document.width} x ${document.height}`);
const res2 = await document.crop({top: 0, bottom: 100, left: 0, right: 100});
console.log(`Document size after 2nd crop: ${document.width} x ${document.height}`);
}, { commandName: 'Crop' }).then(() => {
console.log('Successfully cropped the document');
}).catch(error => {
console.error('Error:', error);
});

/*
Output:
Document size before crop: 9925 x 2125
Document size after crop: 9925 x 2125
Document size after 2nd crop: 9925 x 2125
Successfully cropped the document
*/


So I am stuck, found no other solution. Even Alchemist plugin using the Listener mode didn’t catch the “Export As” descriptor. Also recording it as an regular Photoshop Action and afterwards inspecting the Action using Alchemist Inspector didn’t reveal the “Export As” descriptor.

Anyone here successfully exported an artbord or layer as JPEG in UXP? Or at least found a way to crop a document successfully?

Kind regards,
Alex