压缩工具脚本
现在2019,2020cc的photoshop,动则几百mb体积的.psd文件
找到一个工具,可压缩(某些文件压缩不明显),可方便云文档共享:
/**
* @author Jason
* @email jiangran@126.com
* @name PsDeepCleaner
* @description photoshop metadata deep clean script
*/
function deleteDocumentAncestorsMetadata() {
if(String(app.name).search("Photoshop") > 0) {
if(!documents.length) {
alert("There are no open documents. Please open a file to run this script.")
return;
}
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var xmp = new XMPMeta( activeDocument.xmpMetadata.rawData);
xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
clearDocumentAncestorsForAllLayers(app.activeDocument);
if (app.activeDocument !== mainDocument) {
app.activeDocument.close(SaveOptions.SAVECHANGES);
}else{
app.activeDocument.save();
}
}
}
function clearDocumentAncestorsForAllLayers(doc) {
try {
if (doc == undefined) {
return;
}
for (var i = 0; i < doc.layers.length; i++) {
var curLayer = doc.layers[i];
if (curLayer.typename != "ArtLayer") {
clearDocumentAncestorsForAllLayers(curLayer);
continue;
}
if (curLayer.kind == "LayerKind.SMARTOBJECT") {
app.activeDocument.activeLayer = curLayer;
var idplacedLayerEditContents = stringIDToTypeID("placedLayerEditContents");
var actionDescriptor = new ActionDescriptor();
executeAction(idplacedLayerEditContents, actionDescriptor, DialogModes.NO);
if(app.activeDocument.activeLayer == curLayer){
continue;
}
deleteDocumentAncestorsMetadata()
layerSetStr += ("\n"+curLayer.name)
}
}
} catch (e) {
alert("Layer clean fail.name="+doc+";e="+e)
}
}
var layerSetStr = "";
var mainDocument = app.activeDocument;
function start(){
deleteDocumentAncestorsMetadata();
alert("Clean finished.\n[doc name]:"+mainDocument.name+"\n[layer set]:"+layerSetStr);
}
try{
if(confirm("Start to clean?")){
start();
}
} catch (e) {
alert("Clean fail.e="+e)
}
其他工具下载:
Jscode1.1版本
就算不做游戏,不需要生成UI,也可以切图导出用