skip to Main Content

I would really appreciate some help/tips as I’m very newbie.
I’m making a WordPress website with a product catalogue of 1500 products. The client gave me an FTP-acces where he has uploaded 15 images (sequencially numbered) per product.

Question 1:
Does anyone know if there is a possibility in WordPress to generate animated gifs or via plug-ins?

Question 2:
If no such plug-in exists, I will have to create animated gifs in Photoshop.
I tried to make a combination of script ‘load files into stack’ and then run an action, but it is still very manual work.
I’m not familiar with scripting, but maybe someone has already done similar work with a script?

Anyway, I appreciate your feedback/effort/tips/help.

Thanks,
Miriam

2

Answers


  1. You can do this in an automated way with ImageMagick at the command-line without needing Photoshop. ImageMagick is ready installed on most Linux distros and available for OSX (via homebrew preferably) and also Windows.

    Let’s say you were given the following 37 frames by your client, here all arranged into a large montage:

    enter image description here

    You can then put them all together into an animated GIF with a 10 centisecond delay between frames at the commandline like this:

    convert -delay 10 frame* result.gif
    

    to get this:

    enter image description here

    Login or Signup to reply.
  2. jpgYup, it’s easier with ImageMagick – The script below will work. I’ve added a second for each frame duration that can be adjusted in the optionals part of the script, right at the top.
    The script also has to save out the PSD created, before using save for web to create the animated gif.

    ImageMagic is your clear choice here.

    // ******************************************************
    //
    // LOAD IMAGES (jpg) AS ANIMATED GIF
    // ******************************************************
    
    // *** MUST HAVE ANIMATION WINDOW OPEN
    // *** SCRIPT WON'T WORK OTHERWISE!
    
    //OPTIONALS
    var frameTime = 1.0;
    var tempName = "temp"; // file name for psd
    
    //pref pixels
    app.preferences.rulerUnits = Units.PIXELS;
    
    var baseDocCreated = false;
    var baseImage = "";
    
    
    var inFolder = Folder.selectDialog("Please select folder to process");
    if (inFolder != null)
    {
      var fileList = inFolder.getFiles(/.(jpg)$/i);
    }
    
    var exportpath = inFolder;
    //alert(inFolder)
    
    // main loop starts here
    for(var a = 0 ;a < fileList.length; a++)
    {
      // load the frames one by one
      var doc = open(fileList[a]);
    
      var tempImage = app.activeDocument.name
      // alert(tempImage)
    
      //create the base document to work with
      if (baseDocCreated == false)
      {
        imageW = app.activeDocument.width.value;
        imageH = app.activeDocument.height.value;
        imageRes = 72;
        imageName = "baseDoc";
        createNewDocument(imageW, imageH, imageRes, imageName)
      }
    
    
      var moveTo = app.documents.getByName(baseImage);
      var moveFrom = app.documents.getByName(tempImage);
      moveImage(moveTo, moveFrom)
    
      //close without saving
      app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    
      var rename = tempImage.substring(0, tempImage.length -4);
      app.activeDocument.activeLayer.name = rename
      // alert(app.activeDocument.activeLayer.name)
    }
    
    
    
    // now deal with the creation
    // of the animated gif
    var myPSD = exportpath + "\" + tempName + ".psd";
    
    // call the source document
    var srcDoc = app.activeDocument;
    
    // remove background layer
    var numOfLayers = srcDoc.layers.length;
    srcDoc.layers[numOfLayers-1].remove();
    
    // save the psd
    psdIt(myPSD);
    
    // get the file path
    var filePath = srcDoc.path;
    
    // create animation frames
    createAnimationFromLayers();
    
    // set frame timing
    setFrameDuration(frameTime);
    
    // save as gif
    SaveGifForWeb(filePath);
    
    //close without saving
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    
    
    
    function createNewDocument(w, h, res, aname)
    {
      // alert(w + "n" + h + "n" + res + "n" + aname)
      var docRef = app.documents.add(w, h, res, aname)
      baseImage = "baseDoc"
      baseDocCreated = true;
      srcDoc = app.activeDocument;
    }
    
    // FUNCTION psdIt (source doc)
    // --------------------------------------------------------
    function psdIt (afilePath)
    {
    
      // save out the psd
      var psdFile = new File(afilePath);
      psdSaveOptions = new PhotoshopSaveOptions();
      psdSaveOptions.embedColorProfile = true;
      psdSaveOptions.alphaChannels = true;  
      activeDocument.saveAs(psdFile, psdSaveOptions, false, Extension.LOWERCASE);
    }
    
    
    function moveImage(to, from)
    {
      //select the tempImage
      app.activeDocument = from;
      // move from tempImage to the baseImage
      var duplicateLayer = activeDocument.activeLayer.duplicate(to)
    }
    
    
    // function SAVE GIF FOR WEB (path, jpeg quality)
    // ----------------------------------------------------------------
    function SaveGifForWeb(saveFile)
    {
      var gifOptions = new ExportOptionsSaveForWeb();
      gifOptions.format = SaveDocumentType.COMPUSERVEGIF;  
      gifOptions.interlaced = false;
      gifOptions.colourCount = 256; 
      gifOptions.optimized = true;
      gifOptions.typename = "GIF"; 
      activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, gifOptions);
    }
    
    function createAnimationFromLayers()
    {
      // =======================================================
      var id9070 = stringIDToTypeID( "animationFramesFromLayers" );
      var desc1033 = new ActionDescriptor();
      executeAction( id9070, desc1033, DialogModes.NO );
    }
    
    
    function addFrameTiming(num)
    {
      // =======================================================
      var id9576 = charIDToTypeID( "setd" );
      var desc1151 = new ActionDescriptor();
      var id9577 = charIDToTypeID( "null" );
      var ref694 = new ActionReference();
      var id9578 = stringIDToTypeID( "animationFrameClass" );
      var id9579 = charIDToTypeID( "Ordn" );
      var id9580 = charIDToTypeID( "Trgt" );
      ref694.putEnumerated( id9578, id9579, id9580 );
      desc1151.putReference( id9577, ref694 );
      var id9581 = charIDToTypeID( "T   " );
      var desc1152 = new ActionDescriptor();
      var id9582 = stringIDToTypeID( "animationFrameDelay" );
      desc1152.putDouble( id9582, num );
      var id9583 = stringIDToTypeID( "animationFrameClass" );
      desc1151.putObject( id9581, id9583, desc1152 );
      executeAction( id9576, desc1151, DialogModes.NO );
    }
    
    function selectAllFrames()
    {
      // =======================================================
      var id3 = stringIDToTypeID( "animationSelectAll" );
      var desc2 = new ActionDescriptor();
      executeAction( id3, desc2, DialogModes.NO );
    }
    
    function setFrameDuration(num)
    {
      selectAllFrames()
      // =======================================================
      var id4 = charIDToTypeID( "setd" );
      var desc3 = new ActionDescriptor();
      var id5 = charIDToTypeID( "null" );
      var ref1 = new ActionReference();
      var id6 = stringIDToTypeID( "animationFrameClass" );
      var id7 = charIDToTypeID( "Ordn" );
      var id8 = charIDToTypeID( "Trgt" );
      ref1.putEnumerated( id6, id7, id8 );
      desc3.putReference( id5, ref1 );
      var id9 = charIDToTypeID( "T   " );
      var desc4 = new ActionDescriptor();
      var id10 = stringIDToTypeID( "animationFrameDelay" );
      desc4.putDouble( id10, num ); //num (duration in seconds)
      var id11 = stringIDToTypeID( "animationFrameClass" );
      desc3.putObject( id9, id11, desc4 );
      executeAction( id4, desc3, DialogModes.NO );
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search