2

是否有任何日曆Photoshop/Illustrator腳本可以自動生成類似於此日曆圖標圖像的日期編號?圖標日曆生成器

enter image description here

我需要日期(1,2,3..31)和名稱每月但.png格式相似的圖標。我無法使用html/css3和jquery來創建圖標。

謝謝你的回答和幫助

+2

使用背景圖片並在上面寫上月份和日期... – planetmaker

回答

1

是的,這是可能的。我喜歡挑戰:)

先用模板圖像開放enter image description here 二創建文件夾的文件夾C:\ TEMP \日曆(或更改腳本的目標路徑)

運行下面的腳本,它」目前月,30至12月01日

// 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文件 - 與SDATE & EDATE(開始&結束日期)定義會產生日期。 enter image description here