酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

PS2024一键修复老照片脚本:代码奉上,附三大注意要点!

```javascript // 创建新动作,用于修复老照片 app.displayDialogs = DialogModes.ERROR; // 设置对话框模式为错误时显示 var doc = app.activeDocument; // 去除划痕和污点 doc.artLayers.add(); doc.activeLayer.name = "Healing"; var healingBrush = new ActionDescriptor(); putUnitDouble(healingBrush, charIDToTypeID('Rds '), charIDToTypeID('#Rds'), 10); executeAction(charIDToTypeID('Hl '), healingBrush, DialogModes.NO); // 调整色彩平衡 doc.artLayers.add(); doc.activeLayer.name = "ColorBalance"; var colorBalance = new ActionDescriptor(); putDouble(colorBalance, stringIDToTypeID("reds"), -5); putDouble(colorBalance, stringIDToTypeID("greens"), 0); putDouble(colorBalance, stringIDToTypeID("blues"), 5); executeAction(stringIDToTypeID("colorBalance"), colorBalance, DialogModes.NO); // 锐化图像 doc.artLayers.add(); doc.activeLayer.name = "Sharpen"; var sharpenFilter = new ActionDescriptor(); putUnitDouble(sharpenFilter, charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), 200); executeAction(charIDToTypeID('shrp'), sharpenFilter, DialogModes.NO); // 添加一点噪点,使修复更自然 doc.artLayers.add(); doc.activeLayer.name = "Noise"; var noiseFilter = new ActionDescriptor(); putUnitDouble(noiseFilter, charIDToTypeID('Amnt'), charIDToTypeID('#Prc'), 3); executeAction(stringIDToTypeID('addNoise'), noiseFilter, DialogModes.NO); // 合并所有图层 doc.flatten(); // 保存文件 var saveFile = new File(doc.path + '/' + doc.name.replace(/\.[^\.]+$/, '') + "_repaired.jpg"); var jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.quality = 12; doc.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE); // 关闭文档 doc.close(SaveOptions.DONOTSAVECHANGES); ``` 三条额外需要注意的逻辑点: - 此脚本假设用户已经打开了一张需要修复的老照片。 - 用户应确保有足够的权限在当前路径下保存文件。 - 执行此脚本前,建议备份原始图片,以防结果不符合预期。 ######[AI写代码神器 | 513点数解答 | 2025-03-10 18:38:18]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]