Skip to main content
TheAzzam
Inspiring
August 23, 2022
Question

Cannot save active layer as jpg using ExtendScript

  • August 23, 2022
  • 1 reply
  • 168 views

This my code:

 

options = new JPEGSaveOptions()
options.quality = 1
options.embedColorProfile = true
imagepath = Folder.temp.fsName + "\\" + "image_to_upload"
jpg = new File(imagepath)
app.activeDocument.saveAs(jpg, options)
 
It works fine if I open an image in Photoshop and then run the code, however, if I do so editing on the image, then it does not work. Only a save-the-document-as window opens up but the jpg is not saved. Any help?
 
This a screenshot of when I run the code but it does not work:

 


 

 
This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
August 23, 2022

@TheAzzam 

 

The layer isn't flattened, so it is not possible to directly save into JPEG... Unless you Save As a Copy, adding the true boolean:

 

app.activeDocument.saveAs(jpg, options, true);