Copy link to clipboard
Copied
Hi guys,
I am new at scripting for Photoshop.
I am using this code for saving as a JPEG but it isn't working:
What is wrong with my code? Please help!
Best regards,
Joseph
You can use a relative path (to the logged-in user account ~) for the open step:
open(new File("~\\Downloads\\Adobe Scripting\\photoshop file test for saveAs.psd"));
Or ExtendScript cross-platform single forward slash directory separators in relative path, rather than escaped Windows OS double back slashes:
open(new File("~/Downloads/Adobe Scripting/photoshop file test for saveAs.psd"));
Try saving to a user folder such as the Desktop or Downloads rather than to the root system level. Al
...Copy link to clipboard
Copied
You can use a relative path (to the logged-in user account ~) for the open step:
open(new File("~\\Downloads\\Adobe Scripting\\photoshop file test for saveAs.psd"));
Or ExtendScript cross-platform single forward slash directory separators in relative path, rather than escaped Windows OS double back slashes:
open(new File("~/Downloads/Adobe Scripting/photoshop file test for saveAs.psd"));
Try saving to a user folder such as the Desktop or Downloads rather than to the root system level. Also, even though a four letter JPEG extension is valid, Photoshop doesn't like them, so use a three letter JPG extension instead:
jpgFile = new File ("~/Desktop/Temp001.jpg");
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 1;
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
Copy link to clipboard
Copied
Hi Stephen. Let me try this out.
Copy link to clipboard
Copied
Hi Stephen,
It worked, YIPEEEEEEEEEEEEEEEE!
This is the code I used:
Copy link to clipboard
Copied
Hi, i made this script some weeks ago, it may help
// Check if Adobe Photoshop application is open
if (app && app.name === "Adobe Photoshop") {
// Get the active document
var doc = app.activeDocument;
// Check if a document is open
if (doc) {
// Set the location where you want to save the JPEG file
var saveFolderPath = "C:\\Users\\User\\Desktop\\test\\";
// Check if the save path exists
var saveFolder = new Folder(saveFolderPath);
if (!saveFolder.exists) {
alert("The specified save folder does not exist.");
} else {
// Get the document name
var docName = doc.name;
// Remove the file extension from the document name, if present
var fileName = docName.replace(/\.[^\.]+$/, "");
// Define the full path for the JPEG file
var savePath = saveFolderPath + fileName + ".jpeg";
// Save the document at the specified location as JPEG
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 10; // Adjust the quality as needed (from 0 to 12)
doc.saveAs(new File(savePath), jpegOptions, true);
}
} else {
alert("No document is open in Photoshop.");
}
} else {
alert("Adobe Photoshop is not open.");
}
Copy link to clipboard
Copied
Thanks Pedro. Let me check it out.