有关Photoshop储存图片过大的解决方案
很小的一个icon居然占内存几M,对于一个优秀的程序媛肯定是不能忍的 hhh~
究其原因,是原数据的内容过大导致。不信,你用记事本打开图片,会发现有种来自Photoshop的叫作DocumentAncestors的数据占了几万行导致文件过大
image.png
那就来段神奇的脚本解决掉数据吧
将以下代码储存为.jsx文件。并在Photoshop中 文件→脚本→浏览 来调用,即可删除图中的该类数据
function deleteDocumentAncestorsMetadata() {
whatApp = String(app.name);//String version of the app name
if(whatApp.search("Photoshop") > 0) { //Check for photoshop specifically, or this will cause errors
//Function Scrubs Document Ancestors from Files
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);
// Begone foul Document Ancestors!
xmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "DocumentAncestors");
app.activeDocument.xmpMetadata.rawData = xmp.serialize();
}
}
//Now run the function to remove the document ancestors
deleteDocumentAncestorsMetadata();
最后来看效果~~
image.png
只有十几KB了,耶~~小伙伴试试去吧
有人说这个应该算是一个bug。这个现象在低版本里没有。
网友评论