Scripting a Save As animated GIF with "loop forever" and name, as a layer name

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

Cyril0001
Posts: 1
Joined: Tue Jul 18, 2017 6:29 pm

Scripting a Save As animated GIF with "loop forever" and name, as a layer name

Postby Cyril0001 » Tue Jul 18, 2017 6:31 pm

I have the script blow that saves JPG using a layer name. It works great.

I am trying to update this script so, that it would save animated GIF with "loop forever" option.

It would be just awesome if there is a possibility to set in the script quantity of GIF's colors (64, 128, 256), Transparency, Dithering and other parameters.

Any help would be very greatly appreciated!
----------------------------

#target photoshop
main();
function main(){
if(!documents.length) return;
try{
var Path= activeDocument.path;
}catch(e){var Path = "~/desktop";}
var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, '');
var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_");
var saveFile= new File(Path + "/" + Name + "-" + layerName + ".jpg");
SaveForWeb(saveFile,80);
}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = jpegQuality;
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}



Return to “Help Me”

Who is online

Users browsing this forum: No registered users and 2 guests