12 Replies Latest reply on Jul 24, 2017 10:40 AM by Cyril500

    Scripting "save as animated GIF" in Photoshop using Gifsicle to set Loop=forever

    Cyril500 Level 1

      My script below saves animated .gif file from Photoshop, but with Looping = 1. I need Looping = forever.
      There is a program, called Gifsicle  http://www.lcdf.org/gifsicle/

      It runs under the command line and does everything with GIF.


      In my case, Gifsicle string looks like that:

      C://gifsicle.exe --batch --loop=forever −−careful *.gif


      Is it possible at all for Photoshop jsx script to run Gifsicle and convert the file on disk AFTER this jsx script saves this file to the disc?


      If yes, can anybody help me to integrate the line above into my "saving gif" script below?



      #target photoshop


      function main(){

      if(!documents.length) return;


      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 + ".gif");



      function SaveForWeb(saveFile) {

      var sfwOptions = new ExportOptionsSaveForWeb();

         sfwOptions.format = SaveDocumentType.COMPUSERVEGIF;

         sfwOptions.includeProfile = false;

         sfwOptions.interlaced = 1;

         sfwOptions.optimized = true;

         sfwOptions.transparency = 1;

         sfwOptions.ColorReductionType = ColorReductionType.SELECTIVE;

         sfwOptions.dither = Dither.NONE; 

         sfwOptions.ditherAmount = 80;

         sfwOptions.webSnap = 0;

         sfwOptions.colors = 128;

      activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);