Creating GIFs in bulk?

Community Beginner ,
Feb 10, 2022 Feb 10, 2022

Copy link to clipboard

Copied

Hi everyone,

I have a folder with 200 subfolders inside each containing 6 images in each. I'm looking to create image to GIFs with them, showing each of the 6 pictures one at a time.

 

There is a website to manually make GIFs but this will take quite a while to do all 200 subfolders.

 

https://imgur.com/a/mFhiTeb - essentially, showing each picture one at a time in a loop.

 

If not, is anyone aware of any other programs which do?

 

Thanks

TOPICS
Windows

Views

189

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
community guidelines

correct answers 2 Correct answers

Adobe Community Professional , Feb 16, 2022 Feb 16, 2022
This is not a very clean script, much of it is converted from an action for fast prototyping. Anyway, it works for one inputFolder variable... #target photoshop var inputFolder = Folder.selectDialog('Please select the input folder:'); cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; function createGIFanimation() { // Create Frame Animation function step1(enabled, withDialog) { if (enabled != undefined && !enabled) r...

Likes

Translate

Translate
Adobe Community Professional , Feb 16, 2022 Feb 16, 2022
The Script does not work here so I cannot test, but does this work for folders in the selected folder?  var theFolder = Folder.selectDialog('Please select the input folder:'); var theFolders = theFolder.getFiles(isFolder); for (var m = 0; m < theFolders.length; m++) { var inputFolder = theFolders[m]; alert (inputFolder) cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; function createGIFanimation() { // Create Frame Animation fun...

Likes

Translate

Translate
Adobe Community Professional ,
Feb 15, 2022 Feb 15, 2022

Copy link to clipboard

Copied

I guess, one could automate the task with a Script in Photoshop. 

Have you found some more efficient/easy approach yet? 

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
community guidelines
Community Beginner ,
Feb 15, 2022 Feb 15, 2022

Copy link to clipboard

Copied

Hi, no unfortunately not - I have absolutely no idea how to even begin to be honest!

I know asking someone to essentially start from scratch on my behalf is incredibly rude so if anyone could point me in the right direction how to get started on doing it, that'd be appreciated.

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
community guidelines
Adobe Community Professional ,
Feb 15, 2022 Feb 15, 2022

Copy link to clipboard

Copied

I've seen scripts that can process files in a top level/root folder, ignoring sub folders.

 

I have also seen scripts that can process all files and folders under the root folder.

 

But I've never seen a script to process a sub folder one at a time.

 

I believe that Image Processor and Image Processor Pro can do this, so it is obviously possible.

 

Worse case, possibly an action could play a script that processes the files in each sub folder, with the action being run by IP or IPP.

 

So work out how to do this for one folder and the other 199 may be "easy".

 

Edit: I'm not sure if these scripts can produce an animated GIF without modifications so this may be harder than expected...

 

 

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

OK, incremental progress...

 

I have a script that does the following:

 

1) Stack all files in an input folder

2) Create frame animation

3) Make frames from layers

4) Select all frames

5) Set animation options delay/time

6) Export save for web as gif animation to input folder

 

So at the moment, if you were happy to select 200 separate input folders, you would have a result...

 

The key to the automation will be step of processing the 200 separate folders individually in a loop.

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Hey Stephen - sounds great, so essentially it'll be a case of when running the script - you'd need to select the subfolders individually?

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied


@Jack23100107ff7r wrote:

Hey Stephen - sounds great, so essentially it'll be a case of when running the script - you'd need to select the subfolders individually?


 

At the moment, yes.

 

As my previous post stated, the challenge for me at least, is scripting a loop to process each sub-folder under the top-level-folder as a separate item, then move on and repeat. Somebody else may be able to provide code for that.

 

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Hey Stephen - thanks for your help here, I'm very very new to Photoshop and the only reason I've bought it is for scripts - just didn't realise how hard it can be do write them!

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied


@Jack23100107ff7r wrote:

Hey Stephen - thanks for your help here, I'm very very new to Photoshop and the only reason I've bought it is for scripts - just didn't realise how hard it can be do write them!


 

If you don't have much experience with Photoshop automation, it may be best to start with actions.

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Does this help? 

var theFolder = Folder.selectDialog ("select folder");
var theFolderFiles = getFoldersInFolders (theFolder, []) ;
alert (theFolderFiles.length+" folders\n\n"+theFolderFiles.join("\n\n"));
////// get files from folders in folder //////
function getFoldersInFolders (theFolder, theArray) {
    var theFiles = theFolder.getFiles();
    for (var m = 0; m < theFiles.length; m++) {
    var thisOne = theFiles[m];
    if (thisOne.constructor == Folder) {
    theArray = getFoldersInFolders (thisOne, theArray);
    theArray.push(retrieveFiles (thisOne, []));
    }
    else {};
    };
    return theArray
    };

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

@c.pfaffenbichler 

Thanks, it would if I could work out how to incorporate it into what I already have! :]

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

@Jack23100107ff7r 

 

Questions:

 

1) Is it acceptable that the files are stacked in alpha/numeric filename order? So file001 is the first frame, file006 is the last frame?

 

2) Do all frames have the same delay? If so, how many seconds between each frame?

 

3) Is it acceptable that the saved gif file is named after the folder and that the gif file is saved in this folder with the original six images?

 

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Hey Stephen,

 

1) Yes this is fine, it's okay for the files to be named in any order - the subfolder names don't really matter at all, after they've been converted to GIFs then I can rename them manually.

 

2) Yes they all have the same delay - the delay time being 2 seconds between each frame (though 1 is also acceptable).

 

3) Yes that's fine 🙂

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Best to get the gif names right up front, but how were you going to rename all the gif files?

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Luckily, the GIF names themselves don't really matter as I can pull the file info using the command prompt & bulk rename using Excel's V-Lookup feature.

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

OK, I would have used Adobe Bridge to filter only view of gif files and show all files from all sub folders and hide folders, then the batch rename feature.

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

This is not a very clean script, much of it is converted from an action for fast prototyping. Anyway, it works for one inputFolder variable...

 

#target photoshop

var inputFolder = Folder.selectDialog('Please select the input folder:');

cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function createGIFanimation() {

  // Create Frame Animation
  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    executeAction(sTID('makeFrameAnimation'), undefined, dialogMode);
  };

  // Make Frames from Layers
  function step2(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    executeAction(sTID('animationFramesFromLayers'), desc1, dialogMode);
  };

  // Extend Frame Selection to all 6 frames
  function step3(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(sTID("animationToFrame"), 5);
    desc1.putBoolean(sTID("animationFramesContiguous"), true);
    executeAction(sTID('animationFrameExtendSelection'), desc1, dialogMode);
  };

  // Set frame delay
  function step4(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(sTID("animationFrameClass"), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putDouble(sTID("animationFrameDelay"), 2); // 2 second frame delay
    desc1.putObject(cTID('T   '), sTID("animationFrameClass"), desc2);
    executeAction(cTID('setd'), desc1, dialogMode);
  };

  // Export to GIF89a
  function step5(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(cTID('Op  '), cTID('SWOp'), cTID('OpSa'));
    desc2.putBoolean(cTID('DIDr'), true);
    desc2.putPath(cTID('In  '), new File( inputFolder )); // export location
    desc2.putEnumerated(cTID('Fmt '), cTID('IRFm'), cTID('GIFf'));
    desc2.putBoolean(cTID('Intr'), false);
    desc2.putEnumerated(cTID('RedA'), cTID('IRRd'), cTID('Sltv'));
    desc2.putBoolean(cTID('RChT'), false);
    desc2.putBoolean(cTID('RChV'), false);
    desc2.putBoolean(cTID('AuRd'), false);
    desc2.putInteger(cTID('NCol'), 256);
    desc2.putInteger(cTID('DChS'), 0);
    desc2.putInteger(cTID('DCUI'), 0);
    desc2.putBoolean(cTID('DChT'), false);
    desc2.putBoolean(cTID('DChV'), false);
    desc2.putInteger(cTID('WebS'), 0);
    desc2.putEnumerated(cTID('TDth'), cTID('IRDt'), cTID('None'));
    desc2.putInteger(cTID('TDtA'), 100);
    desc2.putInteger(cTID('Loss'), 0);
    desc2.putInteger(cTID('LChS'), 0);
    desc2.putInteger(cTID('LCUI'), 100);
    desc2.putBoolean(cTID('LChT'), false);
    desc2.putBoolean(cTID('LChV'), false);
    desc2.putBoolean(cTID('Trns'), true);
    desc2.putBoolean(cTID('Mtt '), true);
    desc2.putEnumerated(cTID('Dthr'), cTID('IRDt'), cTID('Dfsn'));
    desc2.putInteger(cTID('DthA'), 100);
    desc2.putInteger(cTID('MttR'), 255);
    desc2.putInteger(cTID('MttG'), 255);
    desc2.putInteger(cTID('MttB'), 255);
    desc2.putBoolean(cTID('SHTM'), false);
    desc2.putBoolean(cTID('SImg'), true);
    desc2.putEnumerated(cTID('SWsl'), cTID('STsl'), cTID('SLAl'));
    desc2.putEnumerated(cTID('SWch'), cTID('STch'), cTID('CHDc'));
    desc2.putEnumerated(cTID('SWmd'), cTID('STmd'), cTID('MDAl'));
    desc2.putBoolean(cTID('ohXH'), false);
    desc2.putBoolean(cTID('ohIC'), true);
    desc2.putBoolean(cTID('ohAA'), true);
    desc2.putBoolean(cTID('ohQA'), true);
    desc2.putBoolean(cTID('ohCA'), false);
    desc2.putBoolean(cTID('ohIZ'), true);
    desc2.putEnumerated(cTID('ohTC'), cTID('SToc'), cTID('OC03'));
    desc2.putEnumerated(cTID('ohAC'), cTID('SToc'), cTID('OC03'));
    desc2.putInteger(cTID('ohIn'), -1);
    desc2.putEnumerated(cTID('ohLE'), cTID('STle'), cTID('LE03'));
    desc2.putEnumerated(cTID('ohEn'), cTID('STen'), cTID('EN00'));
    desc2.putBoolean(cTID('olCS'), false);
    desc2.putEnumerated(cTID('olEC'), cTID('STst'), cTID('ST00'));
    desc2.putEnumerated(cTID('olWH'), cTID('STwh'), cTID('WH01'));
    desc2.putEnumerated(cTID('olSV'), cTID('STsp'), cTID('SP04'));
    desc2.putEnumerated(cTID('olSH'), cTID('STsp'), cTID('SP04'));
    var list1 = new ActionList();
    var desc3 = new ActionDescriptor();
    desc3.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC00'));
    list1.putObject(cTID('SCnc'), desc3);
    var desc4 = new ActionDescriptor();
    desc4.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC19'));
    list1.putObject(cTID('SCnc'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC28'));
    list1.putObject(cTID('SCnc'), desc5);
    var desc6 = new ActionDescriptor();
    desc6.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc6);
    var desc7 = new ActionDescriptor();
    desc7.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc7);
    var desc8 = new ActionDescriptor();
    desc8.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc8);
    desc2.putList(cTID('olNC'), list1);
    desc2.putBoolean(cTID('obIA'), false);
    desc2.putString(cTID('obIP'), "");
    desc2.putEnumerated(cTID('obCS'), cTID('STcs'), cTID('CS01'));
    var list2 = new ActionList();
    var desc9 = new ActionDescriptor();
    desc9.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC01'));
    list2.putObject(cTID('SCnc'), desc9);
    var desc10 = new ActionDescriptor();
    desc10.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC20'));
    list2.putObject(cTID('SCnc'), desc10);
    var desc11 = new ActionDescriptor();
    desc11.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC02'));
    list2.putObject(cTID('SCnc'), desc11);
    var desc12 = new ActionDescriptor();
    desc12.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC19'));
    list2.putObject(cTID('SCnc'), desc12);
    var desc13 = new ActionDescriptor();
    desc13.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC06'));
    list2.putObject(cTID('SCnc'), desc13);
    var desc14 = new ActionDescriptor();
    desc14.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc14);
    var desc15 = new ActionDescriptor();
    desc15.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc15);
    var desc16 = new ActionDescriptor();
    desc16.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc16);
    var desc17 = new ActionDescriptor();
    desc17.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC22'));
    list2.putObject(cTID('SCnc'), desc17);
    desc2.putList(cTID('ovNC'), list2);
    desc2.putBoolean(cTID('ovCM'), false);
    desc2.putBoolean(cTID('ovCW'), false);
    desc2.putBoolean(cTID('ovCU'), true);
    desc2.putBoolean(cTID('ovSF'), true);
    desc2.putBoolean(cTID('ovCB'), true);
    desc2.putString(cTID('ovSN'), "images");
    desc1.putObject(cTID('Usng'), sTID("SaveForWeb"), desc2);
    executeAction(cTID('Expr'), desc1, dialogMode);
  };

// Stacker

        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        var origUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb|gif)$/i);
        // inputFiles.sort().reverse;
        inputFiles.sort();

        var firstFile = app.open(File(inputFiles[0]));
        var firstFileName = app.activeDocument.name;
        app.activeDocument.duplicate(inputFolder.name.replace(/%20/g, '-'), false); // Name the base file after the input folder
        firstFile.close(SaveOptions.DONOTSAVECHANGES);
        var docStack = app.documents[0];
        app.activeDocument = docStack;
        docStack.activeLayer.name = firstFileName;

        for (var i = 1; i < inputFiles.length; i++) {
            var remainingFiles = app.open(File(inputFiles[i]));
            var fileName = remainingFiles.name;
            remainingFiles.activeLayer.name = fileName;
            remainingFiles.layers[0].duplicate(docStack, ElementPlacement.PLACEATBEGINNING);
            remainingFiles.close(SaveOptions.DONOTSAVECHANGES);
        }

        app.displayDialogs = savedDisplayDialogs;
        app.preferences.rulerUnits = origUnits;
  
  // Call the functions

  step1();  // Create Frame Animation
  step2();  // Make Frames from Layers
  step3();  // Extend Frame Selection to all 6 frames
  step4();  // Set frame delay
  step5();  // Export to GIF89a
    
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

};

createGIFanimation.main = function () {
  createGIFanimation();
};

createGIFanimation.main();

 

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Thank you, I have copied a current .atn file I have and copied this text into it (edited with notepad) but it's saying my version of PS isn't compatible. I'm updating it now to see if that'll do the trick, unless I'm trying to add it in completely wrong?

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Scripts are not Actions, they are usually JavaScript (VB and AppleScript are possible, too), so what about the atn-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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Forget actions for this code, it is self contained to process a single input folder manually selected by the user.

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not word-processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Sorry - was completely misunderstood! Saved it as a .js file in Notepad and when running it as a script in Photoshop it's working great when individually selecting the folders. Thank you very much 🙂 

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Your welcome, with luck somebody can combine the two scripts so that you have full automation rather than semi-automation.

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

The Script does not work here so I cannot test, but does this work for folders in the selected folder? 

var theFolder = Folder.selectDialog('Please select the input folder:');
var theFolders = theFolder.getFiles(isFolder);

for (var m = 0; m < theFolders.length; m++) {
var inputFolder = theFolders[m];
alert (inputFolder)
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };

function createGIFanimation() {

  // Create Frame Animation
  function step1(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    executeAction(sTID('makeFrameAnimation'), undefined, dialogMode);
  };

  // Make Frames from Layers
  function step2(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    executeAction(sTID('animationFramesFromLayers'), desc1, dialogMode);
  };

  // Extend Frame Selection to all 6 frames
  function step3(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(sTID("animationToFrame"), 5);
    desc1.putBoolean(sTID("animationFramesContiguous"), true);
    executeAction(sTID('animationFrameExtendSelection'), desc1, dialogMode);
  };

  // Set frame delay
  function step4(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(sTID("animationFrameClass"), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putDouble(sTID("animationFrameDelay"), 2); // 2 second frame delay
    desc1.putObject(cTID('T   '), sTID("animationFrameClass"), desc2);
    executeAction(cTID('setd'), desc1, dialogMode);
  };

  // Export to GIF89a
  function step5(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var desc2 = new ActionDescriptor();
    desc2.putEnumerated(cTID('Op  '), cTID('SWOp'), cTID('OpSa'));
    desc2.putBoolean(cTID('DIDr'), true);
    desc2.putPath(cTID('In  '), new File( inputFolder )); // export location
    desc2.putEnumerated(cTID('Fmt '), cTID('IRFm'), cTID('GIFf'));
    desc2.putBoolean(cTID('Intr'), false);
    desc2.putEnumerated(cTID('RedA'), cTID('IRRd'), cTID('Sltv'));
    desc2.putBoolean(cTID('RChT'), false);
    desc2.putBoolean(cTID('RChV'), false);
    desc2.putBoolean(cTID('AuRd'), false);
    desc2.putInteger(cTID('NCol'), 256);
    desc2.putInteger(cTID('DChS'), 0);
    desc2.putInteger(cTID('DCUI'), 0);
    desc2.putBoolean(cTID('DChT'), false);
    desc2.putBoolean(cTID('DChV'), false);
    desc2.putInteger(cTID('WebS'), 0);
    desc2.putEnumerated(cTID('TDth'), cTID('IRDt'), cTID('None'));
    desc2.putInteger(cTID('TDtA'), 100);
    desc2.putInteger(cTID('Loss'), 0);
    desc2.putInteger(cTID('LChS'), 0);
    desc2.putInteger(cTID('LCUI'), 100);
    desc2.putBoolean(cTID('LChT'), false);
    desc2.putBoolean(cTID('LChV'), false);
    desc2.putBoolean(cTID('Trns'), true);
    desc2.putBoolean(cTID('Mtt '), true);
    desc2.putEnumerated(cTID('Dthr'), cTID('IRDt'), cTID('Dfsn'));
    desc2.putInteger(cTID('DthA'), 100);
    desc2.putInteger(cTID('MttR'), 255);
    desc2.putInteger(cTID('MttG'), 255);
    desc2.putInteger(cTID('MttB'), 255);
    desc2.putBoolean(cTID('SHTM'), false);
    desc2.putBoolean(cTID('SImg'), true);
    desc2.putEnumerated(cTID('SWsl'), cTID('STsl'), cTID('SLAl'));
    desc2.putEnumerated(cTID('SWch'), cTID('STch'), cTID('CHDc'));
    desc2.putEnumerated(cTID('SWmd'), cTID('STmd'), cTID('MDAl'));
    desc2.putBoolean(cTID('ohXH'), false);
    desc2.putBoolean(cTID('ohIC'), true);
    desc2.putBoolean(cTID('ohAA'), true);
    desc2.putBoolean(cTID('ohQA'), true);
    desc2.putBoolean(cTID('ohCA'), false);
    desc2.putBoolean(cTID('ohIZ'), true);
    desc2.putEnumerated(cTID('ohTC'), cTID('SToc'), cTID('OC03'));
    desc2.putEnumerated(cTID('ohAC'), cTID('SToc'), cTID('OC03'));
    desc2.putInteger(cTID('ohIn'), -1);
    desc2.putEnumerated(cTID('ohLE'), cTID('STle'), cTID('LE03'));
    desc2.putEnumerated(cTID('ohEn'), cTID('STen'), cTID('EN00'));
    desc2.putBoolean(cTID('olCS'), false);
    desc2.putEnumerated(cTID('olEC'), cTID('STst'), cTID('ST00'));
    desc2.putEnumerated(cTID('olWH'), cTID('STwh'), cTID('WH01'));
    desc2.putEnumerated(cTID('olSV'), cTID('STsp'), cTID('SP04'));
    desc2.putEnumerated(cTID('olSH'), cTID('STsp'), cTID('SP04'));
    var list1 = new ActionList();
    var desc3 = new ActionDescriptor();
    desc3.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC00'));
    list1.putObject(cTID('SCnc'), desc3);
    var desc4 = new ActionDescriptor();
    desc4.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC19'));
    list1.putObject(cTID('SCnc'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC28'));
    list1.putObject(cTID('SCnc'), desc5);
    var desc6 = new ActionDescriptor();
    desc6.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc6);
    var desc7 = new ActionDescriptor();
    desc7.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc7);
    var desc8 = new ActionDescriptor();
    desc8.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list1.putObject(cTID('SCnc'), desc8);
    desc2.putList(cTID('olNC'), list1);
    desc2.putBoolean(cTID('obIA'), false);
    desc2.putString(cTID('obIP'), "");
    desc2.putEnumerated(cTID('obCS'), cTID('STcs'), cTID('CS01'));
    var list2 = new ActionList();
    var desc9 = new ActionDescriptor();
    desc9.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC01'));
    list2.putObject(cTID('SCnc'), desc9);
    var desc10 = new ActionDescriptor();
    desc10.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC20'));
    list2.putObject(cTID('SCnc'), desc10);
    var desc11 = new ActionDescriptor();
    desc11.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC02'));
    list2.putObject(cTID('SCnc'), desc11);
    var desc12 = new ActionDescriptor();
    desc12.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC19'));
    list2.putObject(cTID('SCnc'), desc12);
    var desc13 = new ActionDescriptor();
    desc13.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC06'));
    list2.putObject(cTID('SCnc'), desc13);
    var desc14 = new ActionDescriptor();
    desc14.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc14);
    var desc15 = new ActionDescriptor();
    desc15.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc15);
    var desc16 = new ActionDescriptor();
    desc16.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC24'));
    list2.putObject(cTID('SCnc'), desc16);
    var desc17 = new ActionDescriptor();
    desc17.putEnumerated(cTID('ncTp'), cTID('STnc'), cTID('NC22'));
    list2.putObject(cTID('SCnc'), desc17);
    desc2.putList(cTID('ovNC'), list2);
    desc2.putBoolean(cTID('ovCM'), false);
    desc2.putBoolean(cTID('ovCW'), false);
    desc2.putBoolean(cTID('ovCU'), true);
    desc2.putBoolean(cTID('ovSF'), true);
    desc2.putBoolean(cTID('ovCB'), true);
    desc2.putString(cTID('ovSN'), "images");
    desc1.putObject(cTID('Usng'), sTID("SaveForWeb"), desc2);
    executeAction(cTID('Expr'), desc1, dialogMode);
  };

// Stacker

        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        var origUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb|gif)$/i);
        // inputFiles.sort().reverse;
        inputFiles.sort();

        var firstFile = app.open(File(inputFiles[0]));
        var firstFileName = app.activeDocument.name;
        app.activeDocument.duplicate(inputFolder.name.replace(/%20/g, '-'), false); // Name the base file after the input folder
        firstFile.close(SaveOptions.DONOTSAVECHANGES);
        var docStack = app.documents[0];
        app.activeDocument = docStack;
        docStack.activeLayer.name = firstFileName;

        for (var i = 1; i < inputFiles.length; i++) {
            var remainingFiles = app.open(File(inputFiles[i]));
            var fileName = remainingFiles.name;
            remainingFiles.activeLayer.name = fileName;
            remainingFiles.layers[0].duplicate(docStack, ElementPlacement.PLACEATBEGINNING);
            remainingFiles.close(SaveOptions.DONOTSAVECHANGES);
        }

        app.displayDialogs = savedDisplayDialogs;
        app.preferences.rulerUnits = origUnits;
  
  // Call the functions

  step1();  // Create Frame Animation
  step2();  // Make Frames from Layers
  step3();  // Extend Frame Selection to all 6 frames
  step4();  // Set frame delay
  step5();  // Export to GIF89a
    
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

};

createGIFanimation.main = function () {
  createGIFanimation();
};

createGIFanimation.main();
};
function isFolder (theFile) {
  if (theFile.constructor.name == "Folder") {return true}
  else {return false}
};

 

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
community guidelines
Adobe Community Professional ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

@c.pfaffenbichler 

 

Thanks again! Works beautifully in my test setup of 2 folders under a top level folder! I can't see why it wouldn't work for 200!

 

@Jack23100107ff7r 

 

You will likely want to comment out with // double forward-slashes or just delete the 6th line:

 

alert (inputFolder)

 

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
community guidelines
Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Hey @Stephen_A_Marsh and @c.pfaffenbichler 

 

You two are probably the first to ever write something like this which is viewable online.. I was searching for ages and ended up on so many websites albeit to no avail.

 

Thank you both so much. You have saved me a lot of time, the 2nd script also works great and is converting all images in the folders into GIFs.

 

I've got absolutely no idea how you guys manage to write these, they seem to complicated! But thank you so much for sharing your knowledge and helping me out.

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
community guidelines