首页 教程 正文

解决photoshop 储存PSD或jpg文件异常过大的方法

2018.5.16 发布在 教程 栏目

使用Photoshop做图时,会因为某些下载的元素污染数据造成储存的PSD文件虚大,并且影响PS的运行速度,下面我们就来解决这一问题!

千万记得尝试解决前,务必做好备份!!!!

使用方法 /

①将下面这段代码复制粘贴到文本工具当中,另存为 Jsx 格式文件。再 PS 打开有问题的文档,「 文件」——「 脚本」——「 浏览…」选择保存的 Jsx 格式文件即可解决。

②下载我已制作好的Jsx文件然后按方式①执行脚本。

 

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)
}

评论

昵称*

邮箱*

网址


浙公网安备 33010602003558号