Cannot save active layer as jpg using ExtendScript

Explorer ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

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:
TheAzzam_1-1661253128623.png

 


 

 
TOPICS
Actions and scripting , SDK , Windows

Views

36

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

LATEST

@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);

 

dom.png

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines