利用Photoshop javascript 给图片添加拍摄日期(creation date)
来源:互联网 发布:磁力软件 编辑:程序博客网 时间:2024/05/07 16:51
简单的自动化脚本,方便批量作业。
// This script is used to add creation date for each .jpg// in folder specified as workDir and save it with the same// name in another folder specified as saveDir.var workDir = 'C:/Users/ABC/Pictures/Camera/' var saveDir = 'C:/Users/ABC/Pictures/output/' // Get all .jpg files in folder.var processFolder = Folder(workDir)var fileList = processFolder.getFiles(/\.(jpg)$/i);app.bringToFront();// Loop through filesfor (var i = 0; i < fileList.length; i++) { // Only process the returned file objects // The filter 'should' have missed out any folder objects if (fileList[i] instanceof File && fileList[i].hidden == false) {addCreationDateAndSave(fileList[i], new File(saveDir + fileList[i].name))//$.writeln(fileList[i].name) }}function addCreationDateAndSave(srcFile, saveFile) { // Remember current unit settings and then set units to // the value expected by this script var originalUnit = preferences.rulerUnits preferences.rulerUnits = Units.INCHES var fileRef = srcFile var docRef = app.open(fileRef) // Create a new art layer containing text var artLayerRef = docRef.artLayers.add() artLayerRef.kind = LayerKind.TEXT // Set the contents of the text layer. var textItemRef = artLayerRef.textItem // Set text color, font and size textColor = new SolidColor(); textColor.rgb.red = 255 textColor.rgb.green = 255 textColor.rgb.blue = 255 textItemRef.color = textColor textItemRef.font = "Myriad Pro" textItemRef.size = new UnitValue(24, "pt") // Set position of textItem, pre-estimate the width and // height of textItem of contents like '2017/03/30' for // a specified font size. var tHalfWidth = new UnitValue(0.75, "in") var tHeight = new UnitValue(0.3, "in") textItemRef.position = Array(app.activeDocument.width.as("in") * 0.5 -tHalfWidth.as("in"), app.activeDocument.height.as("in") * 0.98 -tHeight.as("in")) // creationDate example: 20170413 var Y = docRef.info.creationDate.substring(0,4) var M = docRef.info.creationDate.substring(4,6) var D = docRef.info.creationDate.substring(6) textItemRef.contents = Y + "/" + M + "/" + D jpgSaveOptions = new JPEGSaveOptions() jpgSaveOptions.embedColorProfile = true jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE jpgSaveOptions.matte = MatteType.NONE jpgSaveOptions.quality = 12 app.activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE) app.activeDocument.close(SaveOptions.DONOTSAVECHANGES) // Restore original ruler unit setting app.preferences.rulerUnits = originalUnit // Release references docRef = null artLayerRef = null textItemRef = null}
阅读全文
0 0
- 利用Photoshop javascript 给图片添加拍摄日期(creation date)
- photoshop给图片添加电视条纹效果
- Photoshop脚本 > 给图片添加噪点
- 如何用photoshop给图片添加水印?
- JavaScript: 给 Date 对象添加格式化方法
- 如何利用Quartz2D给图片添加水印
- 利用JavaScript给Table添加行
- JavaScript利用DOM给页面添加内容
- 给javascript的Date添加parse和format函数
- javascript date日期
- JavaScript Date(日期)对象
- javascript Date日期对象
- JavaScript中的日期(Date)
- JavaScript演示日期(Date)
- JavaScript Date(日期)对象
- javascript Date 日期对象
- 【Javascript】Date 日期对象
- JavaScript 日期对象 Date
- Linux源代码—中断
- change dhcp to static on your localhost ip configuration
- G
- hibernate和mybatis共存问题
- 【JSOI2016】最佳团队
- 利用Photoshop javascript 给图片添加拍摄日期(creation date)
- VLAN小知识
- 各个系统中hosts位置
- Android aapt 生成R.java和package.apk原理解析
- Tomcat在处理GET和POST请求时产生的乱码问题
- Hibernate学习之---Hibernate的体系结构
- 使用HTML编写ERP系统的程式
- Frogger
- vijos 1421 更换轮胎