Scriptlistener: scripting save as GIF with loop endless and file name as layer name

Explorer ,
Jul 21, 2017

Copy link to clipboard

Copied

I have script to export to animated GIF that gives

the file name after the name of the selected Photoshop layer.

It works fine but Looping options is always

set to "ONCE". I need looping to be set "FOREVER".

To solve the problem I am trying to use scriptlistener.

The scriptlistener produces proper .GIF with loop

endless BUT I cannot integrate it properly into

my script that sets the name of the file as

the name of the currently selected layer.

I think the problem is that with scriptlistener

I am using Save For WEB to produce GIF file with

Looping Options: forever. So it just overrides

the file name with new always the same name!

Is there any other way to set loop forever except 

Save For WEB function? What should I log by scriptlistener?

Or how I can use scriptlistener's log in this my script?

PLEASE HELP!!! WOULD BE VERY GRATEFULL!!!

------- here is my script -----------

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

SaveForWeb(saveFile);

}

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

}

--------- END of my script -------------------

----------here is

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

makeGif(saveFile);

}

function makeGif(saveFile){ 

// ======================================================= 

var idExpr = charIDToTypeID( "Expr" ); 

    var desc3 = new ActionDescriptor(); 

    var idUsng = charIDToTypeID( "Usng" ); 

        var desc4 = new ActionDescriptor(); 

        var idOp = charIDToTypeID( "Op  " ); 

        var idSWOp = charIDToTypeID( "SWOp" ); 

        var idOpSa = charIDToTypeID( "OpSa" ); 

        desc4.putEnumerated( idOp, idSWOp, idOpSa ); 

        var idDIDr = charIDToTypeID( "DIDr" ); 

        desc4.putBoolean( idDIDr, true ); 

        var idIn = charIDToTypeID( "In  " ); 

        desc4.putPath( idIn, new File( "D:\\==Result\\10-10" ) ); 

        var idovFN = charIDToTypeID( "ovFN" ); 

        desc4.putString( idovFN, saveFile );//new line 

//        desc4.putString( idovFN, """capricia2.gif""" ); Old line 

        var idFmt = charIDToTypeID( "Fmt " ); 

        var idIRFm = charIDToTypeID( "IRFm" ); 

        var idGIFf = charIDToTypeID( "GIFf" ); 

        desc4.putEnumerated( idFmt, idIRFm, idGIFf ); 

        var idIntr = charIDToTypeID( "Intr" ); 

        desc4.putBoolean( idIntr, true ); 

        var idRedA = charIDToTypeID( "RedA" ); 

        var idIRRd = charIDToTypeID( "IRRd" ); 

        var idSltv = charIDToTypeID( "Sltv" ); 

        desc4.putEnumerated( idRedA, idIRRd, idSltv ); 

        var idRChT = charIDToTypeID( "RChT" ); 

        desc4.putBoolean( idRChT, false ); 

        var idRChV = charIDToTypeID( "RChV" ); 

        desc4.putBoolean( idRChV, false ); 

        var idAuRd = charIDToTypeID( "AuRd" ); 

        desc4.putBoolean( idAuRd, false ); 

        var idNCol = charIDToTypeID( "NCol" ); 

        desc4.putInteger( idNCol, 128 ); 

        var idDChS = charIDToTypeID( "DChS" ); 

        desc4.putInteger( idDChS, 0 ); 

        var idDCUI = charIDToTypeID( "DCUI" ); 

        desc4.putInteger( idDCUI, 0 ); 

        var idDChT = charIDToTypeID( "DChT" ); 

        desc4.putBoolean( idDChT, false ); 

        var idDChV = charIDToTypeID( "DChV" ); 

        desc4.putBoolean( idDChV, false ); 

        var idWebS = charIDToTypeID( "WebS" ); 

        desc4.putInteger( idWebS, 0 ); 

        var idTDth = charIDToTypeID( "TDth" ); 

        var idIRDt = charIDToTypeID( "IRDt" ); 

        var idPtrn = charIDToTypeID( "Ptrn" ); 

        desc4.putEnumerated( idTDth, idIRDt, idPtrn ); 

        var idTDtA = charIDToTypeID( "TDtA" ); 

        desc4.putInteger( idTDtA, 100 ); 

        var idLoss = charIDToTypeID( "Loss" ); 

        desc4.putInteger( idLoss, 0 ); 

        var idLChS = charIDToTypeID( "LChS" ); 

        desc4.putInteger( idLChS, 0 ); 

        var idLCUI = charIDToTypeID( "LCUI" ); 

        desc4.putInteger( idLCUI, 100 ); 

        var idLChT = charIDToTypeID( "LChT" ); 

        desc4.putBoolean( idLChT, false ); 

        var idLChV = charIDToTypeID( "LChV" ); 

        desc4.putBoolean( idLChV, false ); 

        var idTrns = charIDToTypeID( "Trns" ); 

        desc4.putBoolean( idTrns, true ); 

        var idMtt = charIDToTypeID( "Mtt " ); 

        desc4.putBoolean( idMtt, false ); 

        var idDthr = charIDToTypeID( "Dthr" ); 

        var idIRDt = charIDToTypeID( "IRDt" ); 

        var idNone = charIDToTypeID( "None" ); 

        desc4.putEnumerated( idDthr, idIRDt, idNone ); 

        var idDthA = charIDToTypeID( "DthA" ); 

        desc4.putInteger( idDthA, 54 ); 

        var idMttR = charIDToTypeID( "MttR" ); 

        desc4.putInteger( idMttR, 255 ); 

        var idMttG = charIDToTypeID( "MttG" ); 

        desc4.putInteger( idMttG, 255 ); 

        var idMttB = charIDToTypeID( "MttB" ); 

        desc4.putInteger( idMttB, 255 ); 

        var idSHTM = charIDToTypeID( "SHTM" ); 

        desc4.putBoolean( idSHTM, false ); 

        var idSImg = charIDToTypeID( "SImg" ); 

        desc4.putBoolean( idSImg, true ); 

        var idSWsl = charIDToTypeID( "SWsl" ); 

        var idSTsl = charIDToTypeID( "STsl" ); 

        var idSLAl = charIDToTypeID( "SLAl" ); 

        desc4.putEnumerated( idSWsl, idSTsl, idSLAl ); 

        var idSWch = charIDToTypeID( "SWch" ); 

        var idSTch = charIDToTypeID( "STch" ); 

        var idCHsR = charIDToTypeID( "CHsR" ); 

        desc4.putEnumerated( idSWch, idSTch, idCHsR ); 

        var idSWmd = charIDToTypeID( "SWmd" ); 

        var idSTmd = charIDToTypeID( "STmd" ); 

        var idMDCp = charIDToTypeID( "MDCp" ); 

        desc4.putEnumerated( idSWmd, idSTmd, idMDCp ); 

        var idohXH = charIDToTypeID( "ohXH" ); 

        desc4.putBoolean( idohXH, false ); 

        var idohIC = charIDToTypeID( "ohIC" ); 

        desc4.putBoolean( idohIC, true ); 

        var idohAA = charIDToTypeID( "ohAA" ); 

        desc4.putBoolean( idohAA, true ); 

        var idohQA = charIDToTypeID( "ohQA" ); 

        desc4.putBoolean( idohQA, true ); 

        var idohCA = charIDToTypeID( "ohCA" ); 

        desc4.putBoolean( idohCA, false ); 

        var idohIZ = charIDToTypeID( "ohIZ" ); 

        desc4.putBoolean( idohIZ, true ); 

        var idohTC = charIDToTypeID( "ohTC" ); 

        var idSToc = charIDToTypeID( "SToc" ); 

        var idOCzerothree = charIDToTypeID( "OC03" ); 

        desc4.putEnumerated( idohTC, idSToc, idOCzerothree ); 

        var idohAC = charIDToTypeID( "ohAC" ); 

        var idSToc = charIDToTypeID( "SToc" ); 

        var idOCzerothree = charIDToTypeID( "OC03" ); 

        desc4.putEnumerated( idohAC, idSToc, idOCzerothree ); 

        var idohIn = charIDToTypeID( "ohIn" ); 

        desc4.putInteger( idohIn, -1 ); 

        var idohLE = charIDToTypeID( "ohLE" ); 

        var idSTle = charIDToTypeID( "STle" ); 

        var idLEzerothree = charIDToTypeID( "LE03" ); 

        desc4.putEnumerated( idohLE, idSTle, idLEzerothree ); 

        var idohEn = charIDToTypeID( "ohEn" ); 

        var idSTen = charIDToTypeID( "STen" ); 

        var idENzerozero = charIDToTypeID( "EN00" ); 

        desc4.putEnumerated( idohEn, idSTen, idENzerozero ); 

        var idolCS = charIDToTypeID( "olCS" ); 

        desc4.putBoolean( idolCS, false ); 

        var idolEC = charIDToTypeID( "olEC" ); 

        var idSTst = charIDToTypeID( "STst" ); 

        var idSTzerozero = charIDToTypeID( "ST00" ); 

        desc4.putEnumerated( idolEC, idSTst, idSTzerozero ); 

        var idolWH = charIDToTypeID( "olWH" ); 

        var idSTwh = charIDToTypeID( "STwh" ); 

        var idWHzeroone = charIDToTypeID( "WH01" ); 

        desc4.putEnumerated( idolWH, idSTwh, idWHzeroone ); 

        var idolSV = charIDToTypeID( "olSV" ); 

        var idSTsp = charIDToTypeID( "STsp" ); 

        var idSPzerofour = charIDToTypeID( "SP04" ); 

        desc4.putEnumerated( idolSV, idSTsp, idSPzerofour ); 

        var idolSH = charIDToTypeID( "olSH" ); 

        var idSTsp = charIDToTypeID( "STsp" ); 

        var idSPzerofour = charIDToTypeID( "SP04" ); 

        desc4.putEnumerated( idolSH, idSTsp, idSPzerofour ); 

        var idolNC = charIDToTypeID( "olNC" ); 

            var list1 = new ActionList(); 

                var desc5 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerozero = charIDToTypeID( "NC00" ); 

                desc5.putEnumerated( idncTp, idSTnc, idNCzerozero ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc5 ); 

                var desc6 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNConenine = charIDToTypeID( "NC19" ); 

                desc6.putEnumerated( idncTp, idSTnc, idNConenine ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc6 ); 

                var desc7 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwoeight = charIDToTypeID( "NC28" ); 

                desc7.putEnumerated( idncTp, idSTnc, idNCtwoeight ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc7 ); 

                var desc8 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc8.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc8 ); 

                var desc9 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc9.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc9 ); 

                var desc10 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc10.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc10 ); 

        desc4.putList( idolNC, list1 ); 

        var idobIA = charIDToTypeID( "obIA" ); 

        desc4.putBoolean( idobIA, false ); 

        var idobIP = charIDToTypeID( "obIP" ); 

        desc4.putString( idobIP, """""" ); 

        var idobCS = charIDToTypeID( "obCS" ); 

        var idSTcs = charIDToTypeID( "STcs" ); 

        var idCSzeroone = charIDToTypeID( "CS01" ); 

        desc4.putEnumerated( idobCS, idSTcs, idCSzeroone ); 

        var idovNC = charIDToTypeID( "ovNC" ); 

            var list2 = new ActionList(); 

                var desc11 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzeroone = charIDToTypeID( "NC01" ); 

                desc11.putEnumerated( idncTp, idSTnc, idNCzeroone ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc11 ); 

                var desc12 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwozero = charIDToTypeID( "NC20" ); 

                desc12.putEnumerated( idncTp, idSTnc, idNCtwozero ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc12 ); 

                var desc13 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerotwo = charIDToTypeID( "NC02" ); 

                desc13.putEnumerated( idncTp, idSTnc, idNCzerotwo ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc13 ); 

                var desc14 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNConenine = charIDToTypeID( "NC19" ); 

                desc14.putEnumerated( idncTp, idSTnc, idNConenine ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc14 ); 

                var desc15 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerosix = charIDToTypeID( "NC06" ); 

                desc15.putEnumerated( idncTp, idSTnc, idNCzerosix ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc15 ); 

                var desc16 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc16.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc16 ); 

                var desc17 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc17.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc17 ); 

                var desc18 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc18.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc18 ); 

                var desc19 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwotwo = charIDToTypeID( "NC22" ); 

                desc19.putEnumerated( idncTp, idSTnc, idNCtwotwo ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc19 ); 

        desc4.putList( idovNC, list2 ); 

        var idovCM = charIDToTypeID( "ovCM" ); 

        desc4.putBoolean( idovCM, false ); 

        var idovCW = charIDToTypeID( "ovCW" ); 

        desc4.putBoolean( idovCW, true ); 

        var idovCU = charIDToTypeID( "ovCU" ); 

        desc4.putBoolean( idovCU, true ); 

        var idovSF = charIDToTypeID( "ovSF" ); 

        desc4.putBoolean( idovSF, true ); 

        var idovCB = charIDToTypeID( "ovCB" ); 

        desc4.putBoolean( idovCB, true ); 

        var idovSN = charIDToTypeID( "ovSN" ); 

        desc4.putString( idovSN, """images""" ); 

    var idSaveForWeb = stringIDToTypeID( "SaveForWeb" ); 

    desc3.putObject( idUsng, idSaveForWeb, desc4 ); 

executeAction( idExpr, desc3, DialogModes.NO ); 

}

------- END of scriptlistener ---------------

TOPICS
Actions and scripting

Views

1.4K

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

Scriptlistener: scripting save as GIF with loop endless and file name as layer name

Explorer ,
Jul 21, 2017

Copy link to clipboard

Copied

I have script to export to animated GIF that gives

the file name after the name of the selected Photoshop layer.

It works fine but Looping options is always

set to "ONCE". I need looping to be set "FOREVER".

To solve the problem I am trying to use scriptlistener.

The scriptlistener produces proper .GIF with loop

endless BUT I cannot integrate it properly into

my script that sets the name of the file as

the name of the currently selected layer.

I think the problem is that with scriptlistener

I am using Save For WEB to produce GIF file with

Looping Options: forever. So it just overrides

the file name with new always the same name!

Is there any other way to set loop forever except 

Save For WEB function? What should I log by scriptlistener?

Or how I can use scriptlistener's log in this my script?

PLEASE HELP!!! WOULD BE VERY GRATEFULL!!!

------- here is my script -----------

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

SaveForWeb(saveFile);

}

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

}

--------- END of my script -------------------

----------here is

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

makeGif(saveFile);

}

function makeGif(saveFile){ 

// ======================================================= 

var idExpr = charIDToTypeID( "Expr" ); 

    var desc3 = new ActionDescriptor(); 

    var idUsng = charIDToTypeID( "Usng" ); 

        var desc4 = new ActionDescriptor(); 

        var idOp = charIDToTypeID( "Op  " ); 

        var idSWOp = charIDToTypeID( "SWOp" ); 

        var idOpSa = charIDToTypeID( "OpSa" ); 

        desc4.putEnumerated( idOp, idSWOp, idOpSa ); 

        var idDIDr = charIDToTypeID( "DIDr" ); 

        desc4.putBoolean( idDIDr, true ); 

        var idIn = charIDToTypeID( "In  " ); 

        desc4.putPath( idIn, new File( "D:\\==Result\\10-10" ) ); 

        var idovFN = charIDToTypeID( "ovFN" ); 

        desc4.putString( idovFN, saveFile );//new line 

//        desc4.putString( idovFN, """capricia2.gif""" ); Old line 

        var idFmt = charIDToTypeID( "Fmt " ); 

        var idIRFm = charIDToTypeID( "IRFm" ); 

        var idGIFf = charIDToTypeID( "GIFf" ); 

        desc4.putEnumerated( idFmt, idIRFm, idGIFf ); 

        var idIntr = charIDToTypeID( "Intr" ); 

        desc4.putBoolean( idIntr, true ); 

        var idRedA = charIDToTypeID( "RedA" ); 

        var idIRRd = charIDToTypeID( "IRRd" ); 

        var idSltv = charIDToTypeID( "Sltv" ); 

        desc4.putEnumerated( idRedA, idIRRd, idSltv ); 

        var idRChT = charIDToTypeID( "RChT" ); 

        desc4.putBoolean( idRChT, false ); 

        var idRChV = charIDToTypeID( "RChV" ); 

        desc4.putBoolean( idRChV, false ); 

        var idAuRd = charIDToTypeID( "AuRd" ); 

        desc4.putBoolean( idAuRd, false ); 

        var idNCol = charIDToTypeID( "NCol" ); 

        desc4.putInteger( idNCol, 128 ); 

        var idDChS = charIDToTypeID( "DChS" ); 

        desc4.putInteger( idDChS, 0 ); 

        var idDCUI = charIDToTypeID( "DCUI" ); 

        desc4.putInteger( idDCUI, 0 ); 

        var idDChT = charIDToTypeID( "DChT" ); 

        desc4.putBoolean( idDChT, false ); 

        var idDChV = charIDToTypeID( "DChV" ); 

        desc4.putBoolean( idDChV, false ); 

        var idWebS = charIDToTypeID( "WebS" ); 

        desc4.putInteger( idWebS, 0 ); 

        var idTDth = charIDToTypeID( "TDth" ); 

        var idIRDt = charIDToTypeID( "IRDt" ); 

        var idPtrn = charIDToTypeID( "Ptrn" ); 

        desc4.putEnumerated( idTDth, idIRDt, idPtrn ); 

        var idTDtA = charIDToTypeID( "TDtA" ); 

        desc4.putInteger( idTDtA, 100 ); 

        var idLoss = charIDToTypeID( "Loss" ); 

        desc4.putInteger( idLoss, 0 ); 

        var idLChS = charIDToTypeID( "LChS" ); 

        desc4.putInteger( idLChS, 0 ); 

        var idLCUI = charIDToTypeID( "LCUI" ); 

        desc4.putInteger( idLCUI, 100 ); 

        var idLChT = charIDToTypeID( "LChT" ); 

        desc4.putBoolean( idLChT, false ); 

        var idLChV = charIDToTypeID( "LChV" ); 

        desc4.putBoolean( idLChV, false ); 

        var idTrns = charIDToTypeID( "Trns" ); 

        desc4.putBoolean( idTrns, true ); 

        var idMtt = charIDToTypeID( "Mtt " ); 

        desc4.putBoolean( idMtt, false ); 

        var idDthr = charIDToTypeID( "Dthr" ); 

        var idIRDt = charIDToTypeID( "IRDt" ); 

        var idNone = charIDToTypeID( "None" ); 

        desc4.putEnumerated( idDthr, idIRDt, idNone ); 

        var idDthA = charIDToTypeID( "DthA" ); 

        desc4.putInteger( idDthA, 54 ); 

        var idMttR = charIDToTypeID( "MttR" ); 

        desc4.putInteger( idMttR, 255 ); 

        var idMttG = charIDToTypeID( "MttG" ); 

        desc4.putInteger( idMttG, 255 ); 

        var idMttB = charIDToTypeID( "MttB" ); 

        desc4.putInteger( idMttB, 255 ); 

        var idSHTM = charIDToTypeID( "SHTM" ); 

        desc4.putBoolean( idSHTM, false ); 

        var idSImg = charIDToTypeID( "SImg" ); 

        desc4.putBoolean( idSImg, true ); 

        var idSWsl = charIDToTypeID( "SWsl" ); 

        var idSTsl = charIDToTypeID( "STsl" ); 

        var idSLAl = charIDToTypeID( "SLAl" ); 

        desc4.putEnumerated( idSWsl, idSTsl, idSLAl ); 

        var idSWch = charIDToTypeID( "SWch" ); 

        var idSTch = charIDToTypeID( "STch" ); 

        var idCHsR = charIDToTypeID( "CHsR" ); 

        desc4.putEnumerated( idSWch, idSTch, idCHsR ); 

        var idSWmd = charIDToTypeID( "SWmd" ); 

        var idSTmd = charIDToTypeID( "STmd" ); 

        var idMDCp = charIDToTypeID( "MDCp" ); 

        desc4.putEnumerated( idSWmd, idSTmd, idMDCp ); 

        var idohXH = charIDToTypeID( "ohXH" ); 

        desc4.putBoolean( idohXH, false ); 

        var idohIC = charIDToTypeID( "ohIC" ); 

        desc4.putBoolean( idohIC, true ); 

        var idohAA = charIDToTypeID( "ohAA" ); 

        desc4.putBoolean( idohAA, true ); 

        var idohQA = charIDToTypeID( "ohQA" ); 

        desc4.putBoolean( idohQA, true ); 

        var idohCA = charIDToTypeID( "ohCA" ); 

        desc4.putBoolean( idohCA, false ); 

        var idohIZ = charIDToTypeID( "ohIZ" ); 

        desc4.putBoolean( idohIZ, true ); 

        var idohTC = charIDToTypeID( "ohTC" ); 

        var idSToc = charIDToTypeID( "SToc" ); 

        var idOCzerothree = charIDToTypeID( "OC03" ); 

        desc4.putEnumerated( idohTC, idSToc, idOCzerothree ); 

        var idohAC = charIDToTypeID( "ohAC" ); 

        var idSToc = charIDToTypeID( "SToc" ); 

        var idOCzerothree = charIDToTypeID( "OC03" ); 

        desc4.putEnumerated( idohAC, idSToc, idOCzerothree ); 

        var idohIn = charIDToTypeID( "ohIn" ); 

        desc4.putInteger( idohIn, -1 ); 

        var idohLE = charIDToTypeID( "ohLE" ); 

        var idSTle = charIDToTypeID( "STle" ); 

        var idLEzerothree = charIDToTypeID( "LE03" ); 

        desc4.putEnumerated( idohLE, idSTle, idLEzerothree ); 

        var idohEn = charIDToTypeID( "ohEn" ); 

        var idSTen = charIDToTypeID( "STen" ); 

        var idENzerozero = charIDToTypeID( "EN00" ); 

        desc4.putEnumerated( idohEn, idSTen, idENzerozero ); 

        var idolCS = charIDToTypeID( "olCS" ); 

        desc4.putBoolean( idolCS, false ); 

        var idolEC = charIDToTypeID( "olEC" ); 

        var idSTst = charIDToTypeID( "STst" ); 

        var idSTzerozero = charIDToTypeID( "ST00" ); 

        desc4.putEnumerated( idolEC, idSTst, idSTzerozero ); 

        var idolWH = charIDToTypeID( "olWH" ); 

        var idSTwh = charIDToTypeID( "STwh" ); 

        var idWHzeroone = charIDToTypeID( "WH01" ); 

        desc4.putEnumerated( idolWH, idSTwh, idWHzeroone ); 

        var idolSV = charIDToTypeID( "olSV" ); 

        var idSTsp = charIDToTypeID( "STsp" ); 

        var idSPzerofour = charIDToTypeID( "SP04" ); 

        desc4.putEnumerated( idolSV, idSTsp, idSPzerofour ); 

        var idolSH = charIDToTypeID( "olSH" ); 

        var idSTsp = charIDToTypeID( "STsp" ); 

        var idSPzerofour = charIDToTypeID( "SP04" ); 

        desc4.putEnumerated( idolSH, idSTsp, idSPzerofour ); 

        var idolNC = charIDToTypeID( "olNC" ); 

            var list1 = new ActionList(); 

                var desc5 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerozero = charIDToTypeID( "NC00" ); 

                desc5.putEnumerated( idncTp, idSTnc, idNCzerozero ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc5 ); 

                var desc6 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNConenine = charIDToTypeID( "NC19" ); 

                desc6.putEnumerated( idncTp, idSTnc, idNConenine ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc6 ); 

                var desc7 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwoeight = charIDToTypeID( "NC28" ); 

                desc7.putEnumerated( idncTp, idSTnc, idNCtwoeight ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc7 ); 

                var desc8 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc8.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc8 ); 

                var desc9 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc9.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc9 ); 

                var desc10 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc10.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list1.putObject( idSCnc, desc10 ); 

        desc4.putList( idolNC, list1 ); 

        var idobIA = charIDToTypeID( "obIA" ); 

        desc4.putBoolean( idobIA, false ); 

        var idobIP = charIDToTypeID( "obIP" ); 

        desc4.putString( idobIP, """""" ); 

        var idobCS = charIDToTypeID( "obCS" ); 

        var idSTcs = charIDToTypeID( "STcs" ); 

        var idCSzeroone = charIDToTypeID( "CS01" ); 

        desc4.putEnumerated( idobCS, idSTcs, idCSzeroone ); 

        var idovNC = charIDToTypeID( "ovNC" ); 

            var list2 = new ActionList(); 

                var desc11 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzeroone = charIDToTypeID( "NC01" ); 

                desc11.putEnumerated( idncTp, idSTnc, idNCzeroone ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc11 ); 

                var desc12 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwozero = charIDToTypeID( "NC20" ); 

                desc12.putEnumerated( idncTp, idSTnc, idNCtwozero ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc12 ); 

                var desc13 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerotwo = charIDToTypeID( "NC02" ); 

                desc13.putEnumerated( idncTp, idSTnc, idNCzerotwo ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc13 ); 

                var desc14 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNConenine = charIDToTypeID( "NC19" ); 

                desc14.putEnumerated( idncTp, idSTnc, idNConenine ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc14 ); 

                var desc15 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCzerosix = charIDToTypeID( "NC06" ); 

                desc15.putEnumerated( idncTp, idSTnc, idNCzerosix ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc15 ); 

                var desc16 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc16.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc16 ); 

                var desc17 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc17.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc17 ); 

                var desc18 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwofour = charIDToTypeID( "NC24" ); 

                desc18.putEnumerated( idncTp, idSTnc, idNCtwofour ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc18 ); 

                var desc19 = new ActionDescriptor(); 

                var idncTp = charIDToTypeID( "ncTp" ); 

                var idSTnc = charIDToTypeID( "STnc" ); 

                var idNCtwotwo = charIDToTypeID( "NC22" ); 

                desc19.putEnumerated( idncTp, idSTnc, idNCtwotwo ); 

            var idSCnc = charIDToTypeID( "SCnc" ); 

            list2.putObject( idSCnc, desc19 ); 

        desc4.putList( idovNC, list2 ); 

        var idovCM = charIDToTypeID( "ovCM" ); 

        desc4.putBoolean( idovCM, false ); 

        var idovCW = charIDToTypeID( "ovCW" ); 

        desc4.putBoolean( idovCW, true ); 

        var idovCU = charIDToTypeID( "ovCU" ); 

        desc4.putBoolean( idovCU, true ); 

        var idovSF = charIDToTypeID( "ovSF" ); 

        desc4.putBoolean( idovSF, true ); 

        var idovCB = charIDToTypeID( "ovCB" ); 

        desc4.putBoolean( idovCB, true ); 

        var idovSN = charIDToTypeID( "ovSN" ); 

        desc4.putString( idovSN, """images""" ); 

    var idSaveForWeb = stringIDToTypeID( "SaveForWeb" ); 

    desc3.putObject( idUsng, idSaveForWeb, desc4 ); 

executeAction( idExpr, desc3, DialogModes.NO ); 

}

------- END of scriptlistener ---------------

TOPICS
Actions and scripting

Views

1.4K

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
Jul 21, 2017 0
Most Valuable Participant ,
Jul 21, 2017

Copy link to clipboard

Copied

I just used the scriptlistener get the cod3e recorded for set a frameanimation to loop forever. Here is what I got.

Saved it as Forever.jsx and tested it and it worked.

// =======================================================

var idsetd = charIDToTypeID( "setd" );

    var desc19 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref3 = new ActionReference();

        var idanimationClass = stringIDToTypeID( "animationClass" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref3.putEnumerated( idanimationClass, idOrdn, idTrgt );

    desc19.putReference( idnull, ref3 );

    var idT = charIDToTypeID( "T   " );

        var desc20 = new ActionDescriptor();

        var idanimationLoopEnum = stringIDToTypeID( "animationLoopEnum" );

        var idanimationLoopType = stringIDToTypeID( "animationLoopType" );

        var idanimationLoopForever = stringIDToTypeID( "animationLoopForever" );

        desc20.putEnumerated( idanimationLoopEnum, idanimationLoopType, idanimationLoopForever );

    var idanimationClass = stringIDToTypeID( "animationClass" );

    desc19.putObject( idT, idanimationClass, desc20 );

executeAction( idsetd, desc19, DialogModes.NO );

JJMack

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
Reply
Loading...
Jul 21, 2017 0
Explorer ,
Jul 21, 2017

Copy link to clipboard

Copied

Thank you SOOOOO much, JJMack!!!

I am a newbie! Could you please tell how I can implement your code into my script below?

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

SaveForWeb(saveFile);

}

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

}

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
Reply
Loading...
Jul 21, 2017 0
Most Valuable Participant ,
Jul 21, 2017

Copy link to clipboard

Copied

Use it before using save for web set forever in in the frame animation timeline. Or make it the first part of your save for web function

JJMack

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
Reply
Loading...
Jul 21, 2017 1
Explorer ,
Jul 21, 2017

Copy link to clipboard

Copied

Sorry! I just did not notice the whole 2-nd string (!!!) from your previous message! Sorry!

So, I've made forever.jsx and run it on my animation in Photoshop and get error 8800 The command "Set" is not currently available. Line: 19 (executeAction( idsetd, desc19, DialogModes.NO );)

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
Reply
Loading...
Jul 21, 2017 0
Most Valuable Participant ,
Jul 21, 2017

Copy link to clipboard

Copied

That would be a valid error message if the documents does not have a frame animation timeline.  How can you set a setting that does not exists. The current active document must have a frame animation in order to set it to loop forever. Check you documents timeline is there a frame animation in it????

Capture.jpg

JJMack

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
Reply
Loading...
Jul 21, 2017 1
Explorer ,
Jul 21, 2017

Copy link to clipboard

Copied

I stuck... I have a smooth animation which consists of a bunch of layers of different kinds - smart objects, effects, etc.

2017-07-22_00-20-18.jpg

I cannot find a way to convert these layers into frame animation...

I saw a bunch of "make frame animation from layers" tutorials, but none of them seems to fit my case.

Once I am trying to rasterize smart objects - I loose all animation effects.

Please help me to find the right tutorial or tell me how I can convert this timeline animation into a frame animation. 

Would be very grateful!

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
Reply
Loading...
Jul 21, 2017 0
Explorer ,
Jul 22, 2017

Copy link to clipboard

Copied

My script below saves .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

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

SaveForWeb(saveFile);

}

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

}

http://www.lcdf.org/gifsicle/

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
Reply
Loading...
Jul 22, 2017 0
Most Valuable Participant ,
Jul 22, 2017

Copy link to clipboard

Copied

I gave you the Scriptlistener code the other day. Told you to use it  befire the save for web step.   I created a PSD document from your gif and set the frame animation to once.  Tot can see the in this screen capture.  I then selected you script the the modfication added and you can see the onec was set to forever and the gif saved with a file name of document name - bottom layer name.gif  loops.  The other amation you show is from a video timeline and the forever would need to be set in the save for web step. Of saved with once then open the gif in photoshop and run your script with the set forever in its frame animation timeline.

Capture.jpglogo-Layer-1.gif

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

SetForever();

SaveForWeb(saveFile);

}

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

}

function SetForever() {

var idsetd = charIDToTypeID( "setd" );

    var desc19 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref3 = new ActionReference();

        var idanimationClass = stringIDToTypeID( "animationClass" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref3.putEnumerated( idanimationClass, idOrdn, idTrgt );

    desc19.putReference( idnull, ref3 );

    var idT = charIDToTypeID( "T   " );

        var desc20 = new ActionDescriptor();

        var idanimationLoopEnum = stringIDToTypeID( "animationLoopEnum" );

        var idanimationLoopType = stringIDToTypeID( "animationLoopType" );

        var idanimationLoopForever = stringIDToTypeID( "animationLoopForever" );

        desc20.putEnumerated( idanimationLoopEnum, idanimationLoopType, idanimationLoopForever );

    var idanimationClass = stringIDToTypeID( "animationClass" );

    desc19.putObject( idT, idanimationClass, desc20 );

executeAction( idsetd, desc19, DialogModes.NO );

}

JJMack

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
Reply
Loading...
Jul 22, 2017 0
Explorer ,
Jul 22, 2017

Copy link to clipboard

Copied

Thank you very much for answering JJMack!

You are absolutely right and your Scriptlistener code works perfectly IF
we have FRAME animation - a
s on your example.

On my side, I have prepared TIMELINE animation with complex smart objects (one smart objects inside another), effects, etc. NOT ONLY layers with static pics.

My problem is - I cannot convert TIMELINE animation into FRAME animation!
I saw and follow many tutorials on how to convert layers into frame animation.
But none of them worked for me - once I rasterize smart objects - all my tuned animation ruins.

Obviously, I do something wrong but I cannot understand what exactly!

If you know a right tutorial or can explain to me how to convert complex timeline into frame animation - I would be VERY grateful!

Only after that, I can use your code to create looped forever gif animation.

Please see. This is how my timeline animation looks like.

Scriptlistener code

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
Reply
Loading...
Jul 22, 2017 0
Most Valuable Participant ,
Jul 22, 2017

Copy link to clipboard

Copied

I tried to capture scriptlistener code where I did not set the forever in the frame animation timeline but set it in save for web Dialog.  The Gif saved looped but when I used the scriptlisener code to see if it work it saved a GIF that do not loop. 

I also did not see any anything in Adobe Photoshop Javascript DOM documentin for save for web as GIF and loop forever.  The word forever is not found in the manual. 

What I also wrote is you can open the gif you saved that does not loop in Photoshop and run your script with the set forever code and the gif saved will loop.

JJMack

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
Reply
Loading...
Jul 22, 2017 0
Most Valuable Participant ,
Jul 22, 2017

Copy link to clipboard

Copied

You can convert a video timeline into a working frame animation but it can be quite involved,  If You can save your video timeline as a gif when you open that gif in Photoshop   you have your frame animation. You can set forever. and save it out. Your script could save for web gif once open the gif set forever and re-save the gif.

JJMack

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
Reply
Loading...
Jul 22, 2017 0
Explorer ,
Jul 22, 2017

Copy link to clipboard

Copied

I see... Thank you very much!

If I have to open the saved GIF in Photoshop again... don't you think it would be easier to use not Photoshop but a lightweight third party program to convert GIF that loops once to GIF that loops forever?

I found such a program called Gifsicle www.lcdf.org/gifsicle

And this string in command line "C://gifsicle.exe --batch --loop=forever −−careful *.gif " does all we need!

It should be run when saved by Photoshop GIF is already on the disc. So, AFTER the scripts work.

Could you please tell how to include this string "C://gifsicle.exe --batch --loop=forever −−careful *.gif " into that script?

That should the solution...

  1. #target photoshop 
  2. main(); 
  3. function main(){ 
  4. if(!documents.length) return
  5. try
  6. var Path= activeDocument.path; 
  7. }catch(e){var Path = "~/desktop";} 
  8. var Name = decodeURI(app.activeDocument.name).replace(/\.[^\.]+$/, ''); 
  9. var layerName = app.activeDocument.activeLayer.name.replace(/[:\/\\*\?\"\<\>\|]/g, "_"); 
  10. var saveFile= new File(Path + "/" + Name + "-" + layerName + ".gif"); 
  11. SaveForWeb(saveFile); 
  12.  
  13.  
  14. function SaveForWeb(saveFile) { 
  15. var sfwOptions = new ExportOptionsSaveForWeb(); 
  16.    sfwOptions.format = SaveDocumentType.COMPUSERVEGIF; 
  17.    sfwOptions.includeProfile = false
  18.    sfwOptions.interlaced = 1
  19.    sfwOptions.optimized = true
  20.    sfwOptions.transparency = 1
  21.    sfwOptions.ColorReductionType = ColorReductionType.SELECTIVE; 
  22.    sfwOptions.dither = Dither.NONE;    
  23.    sfwOptions.ditherAmount = 80
  24.    sfwOptions.webSnap = 0
  25.    sfwOptions.colors = 128
  26. activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions); 

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
Reply
Loading...
Jul 22, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

I'm a bit disappointed in your faith in your ability to hack a script like I suggested.   Here is your script.  I only hack scripting. Had a problem using the bottom layer name in the save file name because it has a Blank in it and Blanks are a bit tricky in scripting they become %20 and require special handling at time. Open did not work because of that. So I change the savefile name to DocName-Animation.gif.

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

var saveFile= new File(Path + "/" + Name + "-Animation" + ".gif");

SaveForWeb(saveFile);

open(saveFile); // Open the GIF

SetForever();           // Set Forever

SaveForWeb(saveFile);   // re-save

activeDocument.close(SaveOptions.DONOTSAVECHANGES); //close 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);

}

function SetForever() {

var idsetd = charIDToTypeID( "setd" );

    var desc19 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref3 = new ActionReference();

        var idanimationClass = stringIDToTypeID( "animationClass" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref3.putEnumerated( idanimationClass, idOrdn, idTrgt );

    desc19.putReference( idnull, ref3 );

    var idT = charIDToTypeID( "T   " );

        var desc20 = new ActionDescriptor();

        var idanimationLoopEnum = stringIDToTypeID( "animationLoopEnum" );

        var idanimationLoopType = stringIDToTypeID( "animationLoopType" );

        var idanimationLoopForever = stringIDToTypeID( "animationLoopForever" );

        desc20.putEnumerated( idanimationLoopEnum, idanimationLoopType, idanimationLoopForever );

    var idanimationClass = stringIDToTypeID( "animationClass" );

    desc19.putObject( idT, idanimationClass, desc20 );

executeAction( idsetd, desc19, DialogModes.NO );

}

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

Please do not be disappointed!

I try really hard ... I need it VERY MUCH!

Most likely, I do something wrong. But I do not understand what exactly. Please advise!

Please look.

Here is my psd animation:

http://12-50.com/111/9-gif.psd

Here is the script file:
http://12-50.com/111/__saveloopgif.jsx

below is the result I get after the scripts works from the psd animation - as you see I get not animated gif.


Besides, the file name after layer name is a crucial part of the script - it is crucial for my workflow!

9-gif-Animation.gif

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

Cyril500  wrote

Could you please tell how to include this string "C://gifsicle.exe --batch --loop=forever −−careful *.gif " into that script?

That would require much more complex code then Open, Set, Save, Close.  Here is a script I use protrace.exe in.  If you want you can look at its code and hack something like it into your script.

/* ==========================================================

// 2014  John J. McAssey (JJMack)

// ======================================================= */

// This script is supplied as is. It is provided as freeware.

// The author accepts no liability for any problems arising from its use.

/* Help Category note tag menu can be used to place script in automate menu

<javascriptresource>

<about>$$$/JavaScripts/potrace/About=JJMack's protrace Script.^r^rCopyright 2014 Mouseprints.^r^rDefine custom shape for the document and add shape layer on top </about>

<category>JJMack's Script</category>

</javascriptresource>

*/

// enable double-clicking from Mac Finder or Windows Explorer

#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events

app.bringToFront();

// ensure at least one document open

if (!documents.length) alert('There are no documents open.', 'No Document');

else {

// declare Global variables

//main(); // at least one document exists proceed

app.activeDocument.suspendHistory('portace','main()');

}

///////////////////////////////////////////////////////////////////////////////

//                            main function                                  //

///////////////////////////////////////////////////////////////////////////////

function main() {

// declare local variables

var orig_ruler_units = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS

try {code();}

catch(e) {alert(e + ': on line ' + e.line, 'Script Error', true);} // display error message if something goes wrong

app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings

}

///////////////////////////////////////////////////////////////////////////////

//                           main function end                               //

///////////////////////////////////////////////////////////////////////////////

function code() {

var scriptLocation = String(findScript());

var replacewithblanks = "";

while (scriptLocation.indexOf("%20") != -1 ) {

   replacewithblanks = replacewithblanks + scriptLocation.substr(0, scriptLocation.indexOf("%20")) + " ";

scriptLocation = scriptLocation.substr(scriptLocation.indexOf("%20") + 3 ,);

}

scriptLocation = replacewithblanks + scriptLocation;

var path = "";

if(scriptLocation.indexOf("/") ==  0 ) {

path = path + scriptLocation.substr(1, 1) + ":\\";

scriptLocation = scriptLocation.substr(scriptLocation.indexOf("/") + 3 ,);

}

while (scriptLocation.indexOf("/") != -1 ) {

path= path + scriptLocation.substr(0, scriptLocation.indexOf("/")) + "\\";

scriptLocation = scriptLocation.substr(scriptLocation.indexOf("/") + 1 ,);

}

scriptLocation = path + scriptLocation;

var program = path + "potrace.exe";

var options="";  

//options=prompt("Enter any Potrace options",options);                               // Best to default and just work on source image

var Name = app.activeDocument.name;                                                 // get name 

if (Name.indexOf(".") != -1 ) Name=Name.substr(0,Name.lastIndexOf("."));            // strip off any extension

Name=Name + " " + suffix();                                                         // add a suffix

var testpbm = new File(Folder.temp + "/" + Name +".pbm");                           // output pbm files

if (testpbm.exists) testpbm.remove();                                               // delete if it exists

var testeps = new File(Folder.temp + "/" + Name +".eps");                           // output eps files

if (testeps.exists) testeps.remove();                                               // delete if it exists

app.activeDocument.artLayers.add();                                                 // Add a Layer so save will not switch documents

SavePBM(testpbm);                                                                   // save active document as a pbm file 

app.activeDocument.activeLayer.remove();                                            // remove added layer

if (!testpbm.exists) {alert('Could not save "' + testpbm + '"'); return;}           // return if it did not save as a pbm

var pbmName = $.getenv("USERPROFILE") +"\\AppData\\Local\\Temp\\"  + Name + ".pbm"; // develop standard windows file name of pbm file

StartPgm(path,program,options,pbmName);                                             // Create eps file

app.refresh();                                                                      // slow down Photoshop with a refresh

for (var i=0;i<100000;i++) { if (!testeps.exists) break; }                          // wait a short time before forcing a pause

if (!testeps.exists) {alert('File "' + testeps + '" was not cteated yet'); }        // force a pause

if (!testeps.exists) {alert('File "' + testeps + '" was not cteated'); return;}     // failed to create the eps file

//app.load(testeps); // load it into a document

openEPS(testeps); // load it into a document use 72 dpi

var sb=DefineShape(Name);                                                           // define custom shape

if (sb!= false) {                                                                   // shape bounds not false

var layers = app.activeDocument.layers;                                         // get layers

app.activeDocument.activeLayer = layers[0];                                    // target top layer

addShape(Name,sb);                                                              // add shape layer to fit canvas

app.activeDocument.activeLayer.name=Name;                                       // tell User the custom shape name is defined

}

else alert('Custom Shape define failed');                                           // tell User the custom shape define failed

}

///////////////////////////////////////////////////////////////////////////////

//                             Start external Program                        //

///////////////////////////////////////////////////////////////////////////////

function StartPgm(pth,pgm,opt,file){

var pgmfile = new File(pgm);

  if(!pgmfile.exists){alert("Program missing 'protrace.exe'\rMust be with script in folder\r" + pth ); return; }

//alert('app.system(Start "' + pgm + '" /D "' + pth + '" /MIN "' + pgm + '" '  + opt + ' "' + file + '"' );

app.system('Start "' + pgm + '" /D  "' + pth + '" /MIN "'  + pgm + '" ' + opt + ' "' + file + '"'  );

};

function suffix() {

var now = (new Date()).valueOf();

var future = (new Date()).valueOf();

while(future == now){

future = (new Date()).valueOf();

}

return future;

}

///////////////////////////////////////////////////////////////////////////////

//        Helper functions mostly scriptlistener Action manager code         //

///////////////////////////////////////////////////////////////////////////////

function SavePBM(file){

var idsave = charIDToTypeID( "save" );

    var desc10 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    desc10.putString( idAs, """Portable Bit Map""" );

    var idIn = charIDToTypeID( "In  " );

    desc10.putPath( idIn, new File( file ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc10.putInteger( idDocI, 344 );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveBegin = stringIDToTypeID( "saveBegin" );

    desc10.putEnumerated( idsaveStage, idsaveStageType, idsaveBegin );

executeAction( idsave, desc10, DialogModes.NO );

var idsave = charIDToTypeID( "save" );

    var desc11 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

    desc11.putString( idAs, """Portable Bit Map""" );

    var idIn = charIDToTypeID( "In  " );

    desc11.putPath( idIn, new File( file ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc11.putInteger( idDocI, 344 );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc11.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

executeAction( idsave, desc11, DialogModes.NO );

}

function openEPS(file) {

var idOpn = charIDToTypeID( "Opn " );

var desc10 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

desc10.putPath( idnull, new File( file ) );

var idAs = charIDToTypeID( "As  " );

var desc11 = new ActionDescriptor();

var idRslt = charIDToTypeID( "Rslt" );

var idRsl = charIDToTypeID( "#Rsl" );

desc11.putUnitDouble( idRslt, idRsl, 72.000000 );

var idAntA = charIDToTypeID( "AntA" );

desc11.putBoolean( idAntA, true );

var idEPSG = charIDToTypeID( "EPSG" );

desc10.putObject( idAs, idEPSG, desc11 );

var idDocI = charIDToTypeID( "DocI" );

desc10.putInteger( idDocI, 545 );

executeAction( idOpn, desc10, DialogModes.NO );

}

function DefineShape(name) {

var rc=false;                                      // set return code to false

try {

// Select Current Layers Transparency

var idsetd = charIDToTypeID( "setd" );

var desc40 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref12 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idfsel = charIDToTypeID( "fsel" );

ref12.putProperty( idChnl, idfsel );

desc40.putReference( idnull, ref12 );

var idT = charIDToTypeID( "T   " );

var ref13 = new ActionReference();

var idChnl = charIDToTypeID( "Chnl" );

var idChnl = charIDToTypeID( "Chnl" );

var idTrsp = charIDToTypeID( "Trsp" );

ref13.putEnumerated( idChnl, idChnl, idTrsp );

desc40.putReference( idT, ref13 );

executeAction( idsetd, desc40, DialogModes.NO );

var SB = app.activeDocument.selection.bounds; // Get the bounds of the selection

top=SB[1].value;

left=SB[0].value;

bottom=SB[3].value;

right=SB[2].value;

rc=top + ":" + left + ":" + bottom + ":" + right;

// Convert selection to path

var idMk = charIDToTypeID( "Mk  " );

var desc41 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref14 = new ActionReference();

var idPath = charIDToTypeID( "Path" );

ref14.putClass( idPath );

desc41.putReference( idnull, ref14 );

var idFrom = charIDToTypeID( "From" );

var ref15 = new ActionReference();

var idcsel = charIDToTypeID( "csel" );

var idfsel = charIDToTypeID( "fsel" );

ref15.putProperty( idcsel, idfsel );

desc41.putReference( idFrom, ref15 );

var idTlrn = charIDToTypeID( "Tlrn" );

var idPxl = charIDToTypeID( "#Pxl" );

desc41.putUnitDouble( idTlrn, idPxl, 2.000000 );

executeAction( idMk, desc41, DialogModes.NO );

// would be good to delete any existing custom shape with this name but Photoshop

// deletes custom shapes by index not name.

// So I add a suffix to the name to make shape names unique.

// define custom shape

var idMk = charIDToTypeID( "Mk  " );

var desc42 = new ActionDescriptor();

var idnull = charIDToTypeID( "null" );

var ref16 = new ActionReference();

var idcustomShape = stringIDToTypeID( "customShape" );

ref16.putClass( idcustomShape );

desc42.putReference( idnull, ref16 );

var idUsng = charIDToTypeID( "Usng" );

var ref17 = new ActionReference();

var idPrpr = charIDToTypeID( "Prpr" );

var idfsel = charIDToTypeID( "fsel" );

ref17.putProperty( idPrpr, idfsel );

var idDcmn = charIDToTypeID( "Dcmn" );

var idOrdn = charIDToTypeID( "Ordn" );

var idTrgt = charIDToTypeID( "Trgt" );

ref17.putEnumerated( idDcmn, idOrdn, idTrgt );

desc42.putReference( idUsng, ref17 );

var idNm = charIDToTypeID( "Nm  " );

desc42.putString( idNm, name );

executeAction( idMk, desc42, DialogModes.NO );

}

//catch(e) {alert(e + ': on line ' + e.line, 'Script Error', true); rc=false; } // display error message if something goes wrong

catch(e) { rc=false; }                                                          // set return code false

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); //close image without saving changes

return rc ;

}

function addShape(name,bounds) {

top=bounds.substr(0,bounds.indexOf(":")); bounds=bounds.substr(bounds.indexOf(":")+1);

left=bounds.substr(0,bounds.indexOf(":")); bounds=bounds.substr(bounds.indexOf(":")+1);

bottom=bounds.substr(0,bounds.indexOf(":")); right=bounds.substr(bounds.indexOf(":")+1);

// Add a Shape at resolution Black Fill no stroke

var idMk = charIDToTypeID( "Mk  " );

    var desc139 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref69 = new ActionReference();

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        ref69.putClass( idcontentLayer );

    desc139.putReference( idnull, ref69 );

    var idUsng = charIDToTypeID( "Usng" );

        var desc140 = new ActionDescriptor();

        var idType = charIDToTypeID( "Type" );

            var desc141 = new ActionDescriptor();

            var idClr = charIDToTypeID( "Clr " );

                var desc142 = new ActionDescriptor();

                var idRd = charIDToTypeID( "Rd  " );

                desc142.putDouble( idRd, 0.000000 );

                var idGrn = charIDToTypeID( "Grn " );

                desc142.putDouble( idGrn, 0.000000 );

                var idBl = charIDToTypeID( "Bl  " );

                desc142.putDouble( idBl, 0.000000 );

            var idRGBC = charIDToTypeID( "RGBC" );

            desc141.putObject( idClr, idRGBC, desc142 );

        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

        desc140.putObject( idType, idsolidColorLayer, desc141 );

        var idShp = charIDToTypeID( "Shp " );

            var desc143 = new ActionDescriptor();

            var idNm = charIDToTypeID( "Nm  " );

            desc143.putString( idNm, name );

            var idTop = charIDToTypeID( "Top " );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc143.putUnitDouble( idTop, idPxl, top );

            var idLeft = charIDToTypeID( "Left" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc143.putUnitDouble( idLeft, idPxl, left );

            var idBtom = charIDToTypeID( "Btom" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc143.putUnitDouble( idBtom, idPxl, bottom );

            var idRght = charIDToTypeID( "Rght" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc143.putUnitDouble( idRght, idPxl, right );

        var idcustomShape = stringIDToTypeID( "customShape" );

        desc140.putObject( idShp, idcustomShape, desc143 );

        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            var desc144 = new ActionDescriptor();

            var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

            desc144.putInteger( idstrokeStyleVersion, 2 );

            var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

            desc144.putBoolean( idstrokeEnabled, false );

            var idfillEnabled = stringIDToTypeID( "fillEnabled" );

            desc144.putBoolean( idfillEnabled, true );

            var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

            var idPnt = charIDToTypeID( "#Pnt" );

            desc144.putUnitDouble( idstrokeStyleLineWidth, idPnt, 2.000000 );

            var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

            var idPnt = charIDToTypeID( "#Pnt" );

            desc144.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

            var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

            desc144.putDouble( idstrokeStyleMiterLimit, 100.000000 );

            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

            var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

            desc144.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

            var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

            desc144.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

            var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );

            desc144.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

            var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

            desc144.putBoolean( idstrokeStyleScaleLock, false );

            var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

            desc144.putBoolean( idstrokeStyleStrokeAdjust, false );

            var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                var list13 = new ActionList();

            desc144.putList( idstrokeStyleLineDashSet, list13 );

            var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

            var idBlnM = charIDToTypeID( "BlnM" );

            var idNrml = charIDToTypeID( "Nrml" );

            desc144.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

            var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

            var idPrc = charIDToTypeID( "#Prc" );

            desc144.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

            var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                var desc145 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc146 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc146.putDouble( idRd, 85.998688 );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc146.putDouble( idGrn, 37.003326 );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc146.putDouble( idBl, 17.999725 );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc145.putObject( idClr, idRGBC, desc146 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc144.putObject( idstrokeStyleContent, idsolidColorLayer, desc145 );

            var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

            desc144.putDouble( idstrokeStyleResolution, 182.880005 );

        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

        desc140.putObject( idstrokeStyle, idstrokeStyle, desc144 );

    var idcontentLayer = stringIDToTypeID( "contentLayer" );

    desc139.putObject( idUsng, idcontentLayer, desc140 );

executeAction( idMk, desc139, DialogModes.NO );

// Toggle visibility of other layers

var idShw = charIDToTypeID( "Shw " );

    var desc694 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var list96 = new ActionList();

            var ref359 = new ActionReference();

            var idLyr = charIDToTypeID( "Lyr " );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref359.putEnumerated( idLyr, idOrdn, idTrgt );

        list96.putReference( ref359 );

    desc694.putList( idnull, list96 );

    var idTglO = charIDToTypeID( "TglO" );

    desc694.putBoolean( idTglO, true );

executeAction( idShw, desc694, DialogModes.NO );

}

// Find the location where this script resides

function findScript() {

var where = "";

try {

FORCEERROR = FORCERRROR;

}

catch(err) {

// alert(err.fileName);

// alert(File(err.fileName).exists);

where = File(err.fileName);

}

return where ;

}

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

Something must be wrong with your setup. If it did not work on your macjine.  I downloaded your PSD and your copy of the modified script. I open your PSD in Photoshop CC 2017 and ran your script. It took Photoshop some time to save out the gifs. Here is the gif produce on my machine. If it is what you want and your machine did ntr produce it you have a problm on you machine.

9-gif-Animation.gif

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

Thank you for the example. I am trying to figure out, but my knowledge in scripting does not allow me to hack it and apply for my case...

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

Does it work or does it not work on your machine?????  If you can not hack you should not be asking for help hacking....

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

I just delete all settings (shift, alt, ctrl when start PS) Photoshop CC 2017.

2017-07-23_16-22-12.jpg

... and got the same result ... not animated gif...

Sorry for delayed replies. I answer as quickly as possible but each my message goes through moderation before publishing ... that is why delays.

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

Did you run the script? I do not see a name like "DocName-Animation.gif" in you post  where is the gif produced if it does not loop you have a problem.

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

2017-07-23_16-36-56.jpg

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

I think you have a problem on your machine.  Delete the GIF open the PSD in Photoshop and run the script.  It should take some time. Monitor the Desktop folder while the script is running.  You should see two .GIF being save. They will have 0 bytes for some time.  Then the temp gif should be gone and the remaining one should be around 2MB in size.

Capture.jpg

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Guide ,
Jul 23, 2017

Copy link to clipboard

Copied

Does this work for you..?

#target photoshop;

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

saveGif(saveFile);

function saveGif(saveFile) {

var desc174 = new ActionDescriptor();

var desc175 = new ActionDescriptor();

desc175.putEnumerated( charIDToTypeID('Op  '), charIDToTypeID('SWOp'), charIDToTypeID('OpSa') );

desc175.putPath( charIDToTypeID('In  '), new File( saveFile ) );

desc175.putEnumerated( charIDToTypeID('Fmt '), charIDToTypeID('IRFm'), charIDToTypeID('GIFf') );

desc175.putBoolean( charIDToTypeID('Intr'), true );

desc175.putEnumerated( charIDToTypeID('RedA'), charIDToTypeID('IRRd'), charIDToTypeID('Sltv') );

desc175.putBoolean( charIDToTypeID('RChT'), false );

desc175.putBoolean( charIDToTypeID('RChV'), false );

desc175.putBoolean( charIDToTypeID('AuRd'), false );

desc175.putInteger( charIDToTypeID('NCol'), 128 );

desc175.putEnumerated( charIDToTypeID('Dthr'), charIDToTypeID('IRDt'), charIDToTypeID('None') );

desc175.putInteger( charIDToTypeID('DthA'), 80 );

desc175.putInteger( charIDToTypeID('DChS'), 0 );

desc175.putInteger( charIDToTypeID('DCUI'), 0 );

desc175.putBoolean( charIDToTypeID('DChT'), false );

desc175.putBoolean( charIDToTypeID('DChV'), false );

desc175.putInteger( charIDToTypeID('WebS'), 0 );

desc175.putEnumerated( charIDToTypeID('TDth'), charIDToTypeID('IRDt'), charIDToTypeID('None') );

desc175.putInteger( charIDToTypeID('TDtA'), 100 );

desc175.putInteger( charIDToTypeID('Loss'), 60 );

desc175.putInteger( charIDToTypeID('LChS'), 0 );

desc175.putInteger( charIDToTypeID('LCUI'), 100 );

desc175.putBoolean( charIDToTypeID('LChT'), false );

desc175.putBoolean( charIDToTypeID('LChV'), false );

desc175.putBoolean( charIDToTypeID('Trns'), true );

desc175.putBoolean( charIDToTypeID('Mtt '), false );

desc175.putInteger( charIDToTypeID('MttR'), 255 );

desc175.putInteger( charIDToTypeID('MttG'), 255 );

desc175.putInteger( charIDToTypeID('MttB'), 255 );

desc175.putBoolean( charIDToTypeID('SHTM'), false );

desc175.putBoolean( charIDToTypeID('SImg'), true );

desc175.putEnumerated( charIDToTypeID('SWsl'), charIDToTypeID('STsl'), charIDToTypeID('SLAl') );

desc175.putEnumerated( charIDToTypeID('SWch'), charIDToTypeID('STch'), charIDToTypeID('CHsR') );

desc175.putEnumerated( charIDToTypeID('SWmd'), charIDToTypeID('STmd'), charIDToTypeID('MDCC') );

desc175.putBoolean( charIDToTypeID('ohXH'), false );

desc175.putBoolean( charIDToTypeID('ohIC'), true );

desc175.putBoolean( charIDToTypeID('ohAA'), true );

desc175.putBoolean( charIDToTypeID('ohQA'), true );

desc175.putBoolean( charIDToTypeID('ohCA'), false );

desc175.putBoolean( charIDToTypeID('ohIZ'), true );

desc175.putEnumerated( charIDToTypeID('ohTC'), charIDToTypeID('SToc'), charIDToTypeID('OC03') );

desc175.putEnumerated( charIDToTypeID('ohAC'), charIDToTypeID('SToc'), charIDToTypeID('OC03') );

desc175.putInteger( charIDToTypeID('ohIn'), -1 );

desc175.putEnumerated( charIDToTypeID('ohLE'), charIDToTypeID('STle'), charIDToTypeID('LE03') );

desc175.putEnumerated( charIDToTypeID('ohEn'), charIDToTypeID('STen'), charIDToTypeID('EN00') );

desc175.putBoolean( charIDToTypeID('olCS'), false );

desc175.putEnumerated( charIDToTypeID('olEC'), charIDToTypeID('STst'), charIDToTypeID('ST00') );

desc175.putEnumerated( charIDToTypeID('olWH'), charIDToTypeID('STwh'), charIDToTypeID('WH01') );

desc175.putEnumerated( charIDToTypeID('olSV'), charIDToTypeID('STsp'), charIDToTypeID('SP04') );

desc175.putEnumerated( charIDToTypeID('olSH'), charIDToTypeID('STsp'), charIDToTypeID('SP04') );

var list9 = new ActionList();

var desc176 = new ActionDescriptor();

desc176.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC00') );

list9.putObject( charIDToTypeID('SCnc'), desc176 );

var desc177 = new ActionDescriptor();

desc177.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC19') );

list9.putObject( charIDToTypeID('SCnc'), desc177 );

var desc178 = new ActionDescriptor();

desc178.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC28') );

list9.putObject( charIDToTypeID('SCnc'), desc178 );

var desc179 = new ActionDescriptor();

desc179.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list9.putObject( charIDToTypeID('SCnc'), desc179 );

var desc180 = new ActionDescriptor();

desc180.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list9.putObject( charIDToTypeID('SCnc'), desc180 );

var desc181 = new ActionDescriptor();

desc181.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list9.putObject( charIDToTypeID('SCnc'), desc181 );

desc175.putList( charIDToTypeID('olNC'), list9 );

desc175.putBoolean( charIDToTypeID('obIA'), false );

desc175.putString( charIDToTypeID('obIP'), '' );

desc175.putEnumerated( charIDToTypeID('obCS'), charIDToTypeID('STcs'), charIDToTypeID('CS01') );

var list10 = new ActionList();

var desc182 = new ActionDescriptor();

desc182.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC01') );

list10.putObject( charIDToTypeID('SCnc'), desc182 );

var desc183 = new ActionDescriptor();

desc183.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC20') );

list10.putObject( charIDToTypeID('SCnc'), desc183 );

var desc184 = new ActionDescriptor();

desc184.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC02') );

list10.putObject( charIDToTypeID('SCnc'), desc184 );

var desc185 = new ActionDescriptor();

desc185.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC19') );

list10.putObject( charIDToTypeID('SCnc'), desc185 );

var desc186 = new ActionDescriptor();

desc186.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC06') );

list10.putObject( charIDToTypeID('SCnc'), desc186 );

var desc187 = new ActionDescriptor();

desc187.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list10.putObject( charIDToTypeID('SCnc'), desc187 );

var desc188 = new ActionDescriptor();

desc188.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list10.putObject( charIDToTypeID('SCnc'), desc188 );

var desc189 = new ActionDescriptor();

desc189.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC24') );

list10.putObject( charIDToTypeID('SCnc'), desc189 );

var desc190 = new ActionDescriptor();

desc190.putEnumerated( charIDToTypeID('ncTp'), charIDToTypeID('STnc'), charIDToTypeID('NC22') );

list10.putObject( charIDToTypeID('SCnc'), desc190 );

desc175.putList( charIDToTypeID('ovNC'), list10 );

desc175.putBoolean( charIDToTypeID('ovCM'), false );

desc175.putBoolean( charIDToTypeID('ovCW'), true );

desc175.putBoolean( charIDToTypeID('ovCU'), true );

desc175.putBoolean( charIDToTypeID('ovSF'), true );

desc175.putBoolean( charIDToTypeID('ovCB'), true );

desc175.putString( charIDToTypeID('ovSN'), 'images' );

desc174.putObject( charIDToTypeID('Usng'), stringIDToTypeID('SaveForWeb'), desc175 );

executeAction( charIDToTypeID('Expr'), desc174, DialogModes.NO );

};

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
Reply
Loading...
Jul 23, 2017 1
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

First I've got 3,7Mb file then it turns to 110K ...

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

Yes. This script works but it loops only once. This is exactly the issue. I have the script that loops once - I need to make it loop forever.

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
Reply
Loading...
Jul 23, 2017 0
Most Valuable Participant ,
Jul 23, 2017

Copy link to clipboard

Copied

Did you monitor the desk top foder while the scriopr ran. Keep refreshing the windows explots with the newest files sorted to the top.  You shoyld see two gig files neinf created thet will hve 0 bytes for some time. ine the ent you should hab one 2MB size Gif the loops.  If the does not work on you machine you have a problem on your machine.  You bottom layer doe not hane a blank in it name soe I restored your file naminstatement anf ran the script you posted back a the statemant changed.  Here is whit  I see nonitoring the desktop and the gif

Capture.jpg9-gif-114.gif

JJMack

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Jul 23, 2017

Copy link to clipboard

Copied

please send me your jsx file

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
Reply
Loading...
Jul 23, 2017 0
Explorer ,
Dec 21, 2020

Copy link to clipboard

Copied

hey @JJMack thank you for this code snippet!

Somehow, I am not able to have ScriptListener plot out the AM code for changing number of loops for a GIF like it did for you.
Would you be able to share the AM code for setting a specific number of loops (i.e not "Forever"). I assume it is something with "Other(#).."?

thnx in advance!

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
Reply
Loading...
Dec 21, 2020 0
Saariko2 LATEST
Explorer ,
Dec 21, 2020

Copy link to clipboard

Copied

Sorry @JJMack 

no need, i got it!
i thought it came from setup in "Save for Web" , but the looping is recroded from the timeline animation options. just recorded it.

 

thnx anyways, you rock!

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
Reply
Loading...
Dec 21, 2020 0