Wordpress插件与Photoshop CC2015:从包含.jpgs

时间:2015-07-15 14:50:14

标签: wordpress action animated-gif photoshop-script

我非常感谢一些帮助/提示,​​因为我是新手。 我正在制作一个Wordpress网站,其产品目录包含1500种产品。客户给了我一个FTP访问,他在每个产品上传了15张图像(顺序编号)。

问题1: 有谁知道Wordpress中是否有可能生成动画GIF或插件?

问题2: 如果不存在这样的插件,我将不得不在Photoshop中创建GIF动画。 我试图将脚本'加载文件组合成'然后运行一个动作,但它仍然是非常手动的工作。 我不熟悉脚本,但也许有人已经用脚本完成了类似的工作?

无论如何,我感谢您的反馈/努力/提示/帮助。

谢谢, 米丽亚姆

2 个答案:

答案 0 :(得分:1)

您可以在命令行中使用ImageMagick以自动方式执行此操作,而无需Photoshop。 ImageMagick已准备好安装在大多数Linux发行版上,可用于OSX(最好通过homebrew)以及Windows。

让我们说你的客户给你以下37帧,这里所有都被安排成一个大的蒙太奇:

enter image description here

然后,您可以将它们全部放在一个动画GIF中,命令行之间的帧间延迟为10厘秒,如下所示:

convert -delay 10 frame* result.gif

得到这个:

enter image description here

答案 1 :(得分:0)

jpgYup,使用ImageMagick更容易 - 下面的脚本可以使用。我为每个帧持续时间添加了一秒,可以在脚本的可选部分中调整,位于顶部。 在使用save for web创建动画gif之前,该脚本还必须保存创建的PSD。

ImageMagic是您明确的选择。

// ******************************************************
//
// 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 );
}