Skip to main content
Participant
July 12, 2013
Question

Script for saving GIF with Animation Loop Endless

  • July 12, 2013
  • 1 reply
  • 4099 views

Hi,

I am searching for a way to use  "save for web" in a Photoshop CC Script.

I already found how to use the "save for web" using Script, but now i am stuck, because i cannot find any information on how to set

that the animation, i want to save as a Animated GIF File, can be set to loop endless.

I already tried to search in all the docs i found about scripting, but there is not a single information about saving gif with animation loop endless...

thanks,

Philipp

This topic has been closed for replies.

1 reply

Inspiring
July 12, 2013

Not sure what you are asking. Looping is an animation/timeline option. You normally set the frame delay and looping before saving. As far as I know you can't set looping during a save with Photoshop( script or manually ).

If you want to set the looping option, you should be able to do that with code from the scriptlistener plug-in. Here is an example from Photoshop CC. Not sure if it will work in older versions because Adobe changed the name of the animation panel to timeline.

function loopForever() {

    var desc = new ActionDescriptor();

        var ref = new ActionReference();

        ref.putEnumerated( stringIDToTypeID('animationClass'), charIDToTID('Ordn'), charIDToTID('Trgt') );

    desc.putReference( charIDToTID('null'), ref );

        var desc1 = new ActionDescriptor();

        desc1.putEnumerated( stringIDToTypeID('animationLoopEnum'), stringIDToTypeID('animationLoopType'), stringIDToTypeID('animationLoopForever') );

    desc.putObject( charIDToTID('T   '), stringIDToTypeID('animationClass'), desc );

    executeAction( charIDToTID('setd'), desc, DialogModes.NO );

};

maedsenAuthor
Participant
July 12, 2013

When you do use "save for web" and select GIF, on the bottom right, the loop mode can be selected. But i think i wouldn't matter to me if it's being set before saving the image.

I already tried to run the script, but somehow

"charIDToTID('Ordn')" for example won't run. Is this the same as charIDToTypeID? because i found charIDToTypeID is a function, but charIDToTID is not...

also the third line from the end, one of the functions seem not to work, i think....

But already you given me a real good answer to what i may try to search for, since i did not actually know that this is set within the timeline, i always used the option within the "save for web" dialog on the bottom-right.

I Solved my own problem ...

I just made Photoshop CC with a script log everything, then gotten to this:

function setLoopForever() {

var idsetd = charIDToTypeID( "setd" );

    var desc5 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idanimationClass = stringIDToTypeID( "animationClass" );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref2.putEnumerated( idanimationClass, idOrdn, idTrgt );

    desc5.putReference( idnull, ref2 );

    var idT = charIDToTypeID( "T   " );

        var desc6 = new ActionDescriptor();

        var idanimationLoopEnum = stringIDToTypeID( "animationLoopEnum" );

        var idanimationLoopType = stringIDToTypeID( "animationLoopType" );

        var idanimationLoopForever = stringIDToTypeID( "animationLoopForever" );

        desc6.putEnumerated( idanimationLoopEnum, idanimationLoopType, idanimationLoopForever );

    var idanimationClass = stringIDToTypeID( "animationClass" );

    desc5.putObject( idT, idanimationClass, desc6 );

executeAction( idsetd, desc5, DialogModes.NO );

}

Works perfect!

Inspiring
July 12, 2013

Yeah, sorry about the typo. It sould have been charIDToTypeID.