图标日历生成器

时间:2015-09-02 09:13:06

标签: image generator photoshop adobe-illustrator photoshop-script

是否有任何日历Photoshop /插图画家脚本可以自动生成类似于此日历图标图像的日期编号?

enter image description here

我需要类似的图标,包括日期(1,2,3..31)和每个月的名字,但是以.png格式。我无法使用html / css3和jquery来创建图标。

感谢您的回答和帮助

1 个答案:

答案 0 :(得分:2)

是的,这是可能的。我喜欢挑战:)

首先打开模板图片enter image description here 第二步创建一个文件夹文件夹C:\ temp \ calendar(或更改脚本中的目标路径)

运行下面的脚本,它将生成与sdate& amp; eDate(开始和结束日期) - 目前是11月30日到12月1日

// Load in background image before running script

// call the source document
var srcDoc = app.activeDocument;

var sDate = new Date("November, 30, 2016 00:00:00");
var eDate = new Date("January,  01, 2017 00:00:00");

var myPath = "c:\\temp\\calendar"

printDate(sDate, eDate, myPath, srcDoc);

//-----------------------------
function printDate(start, end, apath, sauce)
{
  if (start == undefined) return;
  if (end == undefined) return;

  // set long month names
  var monthNames = ["January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
  ];

  str = "";

  // main loop here
  while(start <= end)
  {

    // Display the month, day, and year.
    // getMonth() returns a 0-based number.
    var monthNum = start.getMonth()+1;
    var month = monthNames[monthNum-1].toUpperCase();
    var day   = start.getDate();
    var year  = start.getFullYear();

    // alert(month + " " + day + " " + year);

    // num padding
    if (monthNum < 10) monthNum = "0" + monthNum;
    if (day < 10) day = "0" + day;

    var theDate = "cal_" + monthNum + "_" + day + "_" + year;

    duplicateIt(theDate);

    var day = start.getDate();
    str = (day);         

    var newDate = start.setDate(start.getDate() + 1);

    // fontface, size, R,G,B, text, X, Y
    // print bigmonth
    createText("Arial-BoldMT", 38.0,255, 255, 255, month, 582, 460);

    // print big day
    createText("Arial-BoldMT", 176.0, 0, 0, 0, day, 582, 1144);

    var f  = apath + "\\" + theDate + ".png";

    // alert(f)
    saveAsPNG(f, 10);

    // close that saved png
    app.activeDocument.close();

    // get the original source doc
    app.activeDocument = sauce;

    // reset start
    start = new Date(newDate);
  }
}

// function DUPLICATE IT (str)
// --------------------------------------------------------
function duplicateIt(str)
{
  // duplicate image into new document
  if (arguments.length == 0) str = "temp";

  var id428 = charIDToTypeID( "Dplc" );
  var desc92 = new ActionDescriptor();
  var id429 = charIDToTypeID( "null" );
  var ref27 = new ActionReference();
  var id430 = charIDToTypeID( "Dcmn" );
  var id431 = charIDToTypeID( "Ordn" );
  var id432 = charIDToTypeID( "Frst" );
  ref27.putEnumerated( id430, id431, id432 );
  desc92.putReference( id429, ref27 );
  var id433 = charIDToTypeID( "Nm  " );
  desc92.putString( id433, str ); // name
  executeAction( id428, desc92, DialogModes.NO );
}

// function SAVE JPEG(file name & path)
// --------------------------------------------------------
function saveAsPNG(afilePath)
{
  // flatten it
  activeDocument.flatten();

  // save as a png
  var pngFile = new File(afilePath);
  pngSaveOptions = new PNGSaveOptions();
  pngSaveOptions.embedColorProfile = true;
  pngSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
  pngSaveOptions.matte = MatteType.NONE; pngSaveOptions.quality = 1;

  activeDocument.saveAs(pngFile, pngSaveOptions, false, Extension.LOWERCASE);
}

// function CREATE TEXT(typeface, size, R, G, B, content, Xpos, Ypos, justify)
// --------------------------------------------------------
function createText(fface, size, colR, colG, colB, content, X, Y)
{

  // Add a new layer in the new document
  var artLayerRef = app.activeDocument.artLayers.add()

  // Specify that the layer is a text layer
  artLayerRef.kind = LayerKind.TEXT;
  artLayerRef.name = content;

  //This section defines the color of the text
  textColor = new SolidColor();
  textColor.rgb.red = colR;
  textColor.rgb.green = colG;
  textColor.rgb.blue = colB;

  //Get a reference to the text item so
  // that we can add the text and format it a bit
  textItemRef = artLayerRef.textItem
  textItemRef.font = fface;
  textItemRef.contents = content;
  textItemRef.color = textColor;
  textItemRef.size = size;
  //pixels from the left, pixels from the top
  textItemRef.position = new Array(X, Y)

  just = Justification.CENTER;

  activeDocument.activeLayer.textItem.justification = just;
}

它将它们保存为以日期命名的.PNG文件。 enter image description here