Photoshop EXIF 脚本

news/2025/2/28 9:57:13/

以下代码用ANSI编码保存到 C:\Program Files\Adobe\Adobe Photoshop 2025\Presets\Scripts\AddEXIFFrame.jsx
打开Photoshop,会看到

在这里插入图片描述

效果图:
在这里插入图片描述
在这里插入图片描述

大的文件会自动缩放到小边2000像素。

#target photoshop// covert "2025:02:20 13:11:21" to 2025-02-20 13:11:21
function convertToStandardTime(input) {if(input.length != 19){return input;}/*var parts = input.split(' ');var datePart = parts[0];var timePart = parts[1];var formattedDate = datePart.replace(/:/g, '-').replace(/-([^-]*)$/, ':$1');return formattedDate + ' ' + timePart;*/var arr = input.split('');arr[4] = '-';arr[7] = '-';return arr.join('');
}// **********   DATA FUNCTIONS START  ***************
// Common Data Functions used to gather EXIF data
// Sets image data to a string that will later be used to set into the image
function getExifData(doc) {const exifInfos = {"Producer":"","Model": "","FocalLength": "","FocalLength35mm": "","ExposureTime" : "","ISO" : "","Aperture": "","ExposureBiasValue": "","Lens" : "","DateTimeDigitized": "","DateTime": ""};// Get exif data from filevar exifString = doc.info.exif.toString();const parts = exifString.split(',');// check the data for (i = 0; i < parts.length; i = i + 3) {var key = parts[i];var value = parts[i + 1];switch(key){case "制造":case "Make":exifInfos.Producer = value;break;case "机型":case "Model":exifInfos.Model = value;break;case "焦距":case "Focal Length":exifInfos.FocalLength = value.replace(" mm", "mm");break;case "Focal Length in 35mm Film":exifInfos.FocalLength35mm = value.replace(" mm", "mm");break;case "曝光时间":case "Exposure Time":exifInfos.ExposureTime = value.replace(" sec", "s");break;case "ISO 感光度":case "ISO Speed Ratings":exifInfos.ISO = value;break;case "光圈值":case "Aperture Value":exifInfos.Aperture = value;break;case "曝光补偿值":case "Exposure Bias Value":exifInfos.ExposureBiasValue = value;break;case "EXIF tag 42036":exifInfos.Lens = value;break;case "数字化日期时间":case "Date Time Digitized":exifInfos.DateTimeDigitized = convertToStandardTime(value);break;case "日期时间":case "Date Time":exifInfos.DateTime = convertToStandardTime(value);break;default:break;}}return exifInfos;}function addText(doc, x, y, layer_name, text, color, justification, vertical_degree, anchor_position){var textLayer = doc.artLayers.add();textLayer.kind = LayerKind.TEXT;textLayer.name = layer_name;var textItem = textLayer.textItem;textItem.position = [x, y];textItem.size = 11;textItem.font = "Arial";textItem.tracking = 100;textItem.color = color;textItem.justification = justification;if(vertical_degree != 0){		textItem.contents = "TEXT";textLayer.rotate(vertical_degree, anchor_position);}textItem.contents = text;return textLayer;
}// Define Colors
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
var gray = new SolidColor();
gray.rgb.red = gray.rgb.green = gray.rgb.blue = 127;var textColor = new SolidColor();
textColor.rgb.red = textColor.rgb.green = textColor.rgb.blue = 230;// check image opened.
if (app.documents.length > 0) {var originalRuleUnits = app.preferences.rulerUnits;app.preferences.rulerUnits = Units.PIXELS;var doc = app.activeDocument;var whRatio = doc.width/ doc.height;var resizing = false;var newWidth = doc.width;var newHeight = doc.height;if( whRatio > 1){if(doc.height > 2000) {// resizenewHeight = 2000;newWidth =  newHeight * doc.width / doc.height;resizing = true;}}else {if(doc.width > 2000) {// resizenewWidth = 2000;newHeight = newWidth * doc.height / doc.width;resizing = true;}}if(resizing){try {doc.resizeImage(newWidth, newHeight, null, ResampleMethod.BICUBIC);// alert("Image resized to " + newWidth + "x" + newHeight + " px.");} catch (e) {alert("Failed to resize image:" + e.message);}}var originalWidth = doc.width;var originalHeight = doc.height;var bgLayer = undefined;if (doc.artLayers.length > 0) {bgLayer = doc.artLayers[doc.artLayers.length - 1];bgLayer.isBackgroundLayer = false;}// set marginsvar borderSize = Math.min(originalWidth, originalHeight) * 0.04;if( borderSize < 20) {borderSize = 20;}newWidth = originalWidth + borderSize * 2 + 10;newHeight = originalHeight + borderSize * 2 + 10;// resize cavasdoc.resizeCanvas(newWidth, newHeight, AnchorPosition.MIDDLECENTER);// create frame layervar borderLayer = doc.artLayers.add();borderLayer.name = "Frame";var selection = doc.selection;selection.selectAll();selection.fill(white);selection.stroke(black, borderSize, StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);selection.selectAll();selection.stroke(gray, 2, StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);selection.deselect();if(bgLayer != undefined) {borderLayer.move(bgLayer, ElementPlacement.PLACEAFTER);}else {borderLayer.move(doc, ElementPlacement.PLACEATBEGINNING);}exifInfos = getExifData(doc);var text1 =  exifInfos.FocalLength + ' ' + exifInfos.Aperture + ' ' +exifInfos.ExposureTime + ' ISO' + exifInfos.ISO ;if(exifInfos.ExposureBiasValue == 0){text1 = text1 + ' EV+0.0';}else {text1 = text1 + ' EV' + exifInfos.ExposureBiasValue;}var text3 = exifInfos.Producer + ' ' + exifInfos.Model + ' / ' + exifInfos.Lens;var text2 = exifInfos.DateTimeDigitized;if(text3 == ""){exifInfos.DateTime;}var x = newWidth - borderSize;var y = newHeight - borderSize * 0.5 + 10;addText(doc, x, y , "EXIF Text 1", text1 , textColor, Justification.RIGHT, 0, AnchorPosition.BOTTOMLEFT);x = newWidth - borderSize;y = borderSize * 0.5 + 10;if(text2 != ""){addText(doc, x, y, "EXIF Text 2", text2, textColor, Justification.RIGHT, 0, AnchorPosition.TOPLEFT);}x = borderSize - 10;y = newHeight - borderSize - 20;addText(doc,x , y, "EXIF Text 3",  text3, textColor, Justification.LEFT, -90, AnchorPosition.BOTTOMLEFT);app.preferences.rulerUnits = originalRuleUnits;} else {alert("Open image first");
}

Enjoy!


http://www.ppmy.cn/news/1575474.html

相关文章

基于Python+django+mysql旅游数据爬虫采集可视化分析推荐系统

2024旅游推荐系统爬虫可视化&#xff08;协同过滤算法&#xff09; 基于Pythondjangomysql旅游数据爬虫采集可视化分析推荐系统 有文档说明 部署文档 视频讲解 ✅️基于用户的协同过滤推荐算法 卖价就是标价~ 项目技术栈 Python语言、Django框架、MySQL数据库、requests网络爬虫…

测试的基本概念

需求 需求分为两部分: 用户需求: 可以简单归为甲方提出的要求,或者终端用户使用产品时必须要完成的任务 软件需求: 功能需求,会详细描述开发人员必须实现的软件功能,是测试人员进行测试工作的基本依据 开发模型 当软件工作的范围逐步扩展到了整个软件生命周期,例如软件基本…

小米和华为的需求管理及产品策划

小米与华为在消费者需求洞察和产品策划领域形成了独特的方法论体系&#xff0c;以下基于公开资料及企业白皮书内容&#xff0c;系统梳理其核心框架与实施工具&#xff1a; 一、市场调研方法论 &#xff08;1&#xff09;用户需求洞察体系 小米「用户痛点三筛法」&#xff08;…

IDEA-插件开发踩坑记录-第六坑-UAST依赖问题

背景 简要说明&#xff1a; UAST – Unified Abstract Syntax Tree UAST (Unified Abstract Syntax Tree) is an abstraction layer on the PSI of different programming languages targeting the JVM (Java Virtual Machine). It provides a unified API for working with co…

c++_sort函数

sort介绍 在C/C中&#xff0c;要想应用排序算法&#xff0c;可以使用c语言的qsort&#xff0c;也可以使用c的sort 。 1)qsort 是 C 标准库提供的一个通用排序函数&#xff0c;位于 stdlib.h 头文件中。 qsort 适用于 C 语言中的数组。 2)sort 是 C 中STL的泛型算法&#xf…

在VSCode 中使用通义灵码最新版详细教程

在 VSCode 中使用通义灵码&#xff1a;最新版详细教程与使用场景 Visual Studio Code&#xff08;简称 VSCode&#xff09;是一款由微软开发的轻量级、功能强大的开源代码编辑器&#xff0c;支持多种编程语言&#xff0c;深受开发者喜爱。而通义灵码&#xff08;TONGYI Lingma…

scalefit分析系统-人体工程学分析系统

基于先进的德国scalefit分析系统&#xff0c;可根据职业科学和生物力学参数直接在现场对体力工作量进行可视化和评估&#xff0c;帮助检测疾病、伤害和损害的原因。 据调研&#xff0c;国内整套系统报价在人民币65万左右。包含动捕硬件、分析软件、工程学系统等。 工作站配置要…

文教资料杂志文教资料杂志社文教资料编辑部2024年第19期目录

语言文学研究 “X什么Y”构式主观性与主观化浅析 郑昕怡; 杜诗之“忧”的艺术抒写 李佳欣; 中国儿童绘本发展简史探析 杜娟; 《凝视太阳》的文学伦理学批评解读 张佳圆; 论《哈姆雷特》中的寓言式宇宙观与个体思想的矛盾冲突 张佳佳; 符号象征&#xf…