2014-10-28 79 views
0

我试图从文档中移除颜色配置文件。据我所知,colorProfileName应该是一个字符串或null(如果它没有被分配)。但是,如果是后者,我不能将它分配给一个变量(第3行)。未定义的颜色配置文件

没有try/catch有没有办法解决这个问题?

try { 
    var cp = app.activeDocument.colorProfileName; 
} catch(eek) { 
    alert("no colour profile associated with image"); 
    cp = null; 
} 

if (cp != null) { 
    cp = assignNoColourProfile(cp); 
    if (cp == null) { 
     alert("colour profile now removed"); 
    } 
} 

回答

2

我只能访问到Photoshop CS5和colorProfileName的描述说:

有效,只有当colorProfileType = ColorProfile.CUSTOM或工作。

所以也许这是一个好主意,检查前:

var cp = null; 
if (app.activeDocument.colorProfileType != ColorProfile.NONE) 
    cp = app.activeDocument.colorProfileName; 

迈克尔/汉堡

相关问题