【修改】word,excel。ps考点。对齐判分对错号
This commit is contained in:
306
checkPSD.jsx
306
checkPSD.jsx
@@ -168,13 +168,12 @@ function processLayers(layers, resultArray) {
|
||||
|
||||
// 读取图层样式
|
||||
var styles = getLayerStyles(layer);
|
||||
if (styles) {
|
||||
if (styles && !isEmptyObject(styles)) {
|
||||
info["图层样式"] = styles;
|
||||
}
|
||||
|
||||
// 检测滤镜信息
|
||||
var filterInfo = detectFilters(layer.name);
|
||||
if (filterInfo) {
|
||||
if (filterInfo && !isEmptyObject(filterInfo)) {
|
||||
info["滤镜信息"] = filterInfo;
|
||||
}
|
||||
|
||||
@@ -323,7 +322,7 @@ function processFile(path) {
|
||||
processLayers(doc.layers, result["图层信息"]);
|
||||
|
||||
// 获取智能对象图层数(递归计算)
|
||||
result["智能对象图层数"] = countSmartObjectsRecursive(doc.layers);
|
||||
// result["智能对象图层数"] = countSmartObjectsRecursive(doc.layers);
|
||||
|
||||
// 写入 JSON 文件
|
||||
var baseName = fileRef.name.replace(/\.psd$/i, "");
|
||||
@@ -523,194 +522,178 @@ function getWarpTextProps() {
|
||||
|
||||
|
||||
function getLayerStyles(layer) {
|
||||
var styles = {};
|
||||
|
||||
// ---- 激活图层 ----
|
||||
app.activeDocument.activeLayer = layer;
|
||||
|
||||
// ---- 获取 ActionDescriptor ----
|
||||
var desc;
|
||||
try {
|
||||
// 尝试 CC/2025 方法
|
||||
var ref = new ActionReference();
|
||||
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
|
||||
var desc = executeActionGet(ref);
|
||||
|
||||
if (!desc.hasKey(stringIDToTypeID("layerEffects"))) {
|
||||
$.writeln("图层无 layerEffects:" + layer.name);
|
||||
return null;
|
||||
if (layer.id !== undefined) {
|
||||
ref.putIdentifier(charIDToTypeID("Lyr "), layer.id);
|
||||
} else {
|
||||
throw "CS6 fallback";
|
||||
}
|
||||
desc = executeActionGet(ref);
|
||||
} catch (e) {
|
||||
// CS6 fallback
|
||||
var ref2 = new ActionReference();
|
||||
ref2.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
|
||||
desc = executeActionGet(ref2);
|
||||
}
|
||||
|
||||
// ---- 判断 layerEffects 是否存在 ----
|
||||
if (!desc.hasKey(stringIDToTypeID("layerEffects"))) {
|
||||
$.writeln("图层 " + layer.name + " 没有 layerEffects");
|
||||
return styles; // 空对象
|
||||
}
|
||||
try {
|
||||
var effects = desc.getObjectValue(stringIDToTypeID("layerEffects"));
|
||||
var styles = {};
|
||||
|
||||
// ============ 描边 ===============
|
||||
// ---- 描边 ----
|
||||
if (effects.hasKey(stringIDToTypeID("frameFX"))) {
|
||||
var frameFX = effects.getObjectValue(stringIDToTypeID("frameFX"));
|
||||
var keys = [];
|
||||
for (var i = 0; i < frameFX.count; i++) {
|
||||
keys.push(i + ": " + typeIDToStringID(frameFX.getKey(i)));
|
||||
}
|
||||
var enabled = frameFX.getBoolean(stringIDToTypeID("enabled"));
|
||||
styles["描边_启用"] = frameFX.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (enabled) {
|
||||
if (frameFX.hasKey(stringIDToTypeID("size"))) {
|
||||
styles["描边_大小"] = frameFX.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("color"))) {
|
||||
var colorDesc = frameFX.getObjectValue(stringIDToTypeID("color"));
|
||||
styles["描边_颜色"] = colorDescToHex(colorDesc);
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("style"))) {
|
||||
var posEnum = frameFX.getEnumerationValue(stringIDToTypeID("style"));
|
||||
var posStringID = typeIDToStringID(posEnum);
|
||||
styles["描边_位置"] = getStrokePositionName(posStringID);
|
||||
} else {
|
||||
styles["描边_位置"] = "未知";
|
||||
}
|
||||
|
||||
if (frameFX.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["描边_不透明度"] = Math.round(frameFX.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("mode"))) {
|
||||
var blendMode = frameFX.getEnumerationValue(stringIDToTypeID("mode"));
|
||||
styles["描边_混合模式"] = getBlendModeName(blendMode);
|
||||
if (frameFX.hasKey(stringIDToTypeID("enabled"))) {
|
||||
var enabled = frameFX.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (enabled) {
|
||||
if (frameFX.hasKey(stringIDToTypeID("size"))) {
|
||||
styles["描边_大小"] = frameFX.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["描边_颜色"] = colorDescToHex(frameFX.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("style"))) {
|
||||
var posEnum = frameFX.getEnumerationValue(stringIDToTypeID("style"));
|
||||
var posStringID = typeIDToStringID(posEnum);
|
||||
styles["描边_位置"] = getStrokePositionName(posStringID);
|
||||
} else {
|
||||
styles["描边_位置"] = "未知";
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["描边_不透明度"] = Math.round(frameFX.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
|
||||
}
|
||||
if (frameFX.hasKey(stringIDToTypeID("mode"))) {
|
||||
styles["描边_混合模式"] = getBlendModeName(frameFX.getEnumerationValue(stringIDToTypeID("mode")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============ 内发光 ===============
|
||||
// ---- 内发光 ----
|
||||
if (effects.hasKey(stringIDToTypeID("innerGlow"))) {
|
||||
var innerGlow = effects.getObjectValue(stringIDToTypeID("innerGlow"));
|
||||
// var keys = [];
|
||||
// for (var i = 0; i < innerGlow.count; i++) {
|
||||
// keys.push(i + ": " + typeIDToStringID(innerGlow.getKey(i)));
|
||||
// }
|
||||
styles["内发光_启用"] = innerGlow.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (styles["内发光_启用"]) {
|
||||
if (innerGlow.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["内发光_不透明度"] = Math.round(innerGlow.getUnitDoubleValue(stringIDToTypeID("opacity")) ) + "%";
|
||||
if (innerGlow.hasKey(stringIDToTypeID("enabled"))) {
|
||||
var enabled = innerGlow.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (enabled) {
|
||||
if (innerGlow.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["内发光_不透明度"] = Math.round(innerGlow.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
|
||||
}
|
||||
if (innerGlow.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["内发光_颜色"] = colorDescToHex(innerGlow.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
|
||||
styles["内发光_大小"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
|
||||
}
|
||||
if (innerGlow.hasKey(stringIDToTypeID("mode"))) {
|
||||
var modeID = innerGlow.getEnumerationValue(stringIDToTypeID("mode"));
|
||||
styles["内发光_混合模式"] = getBlendModeName(modeID);
|
||||
}
|
||||
if (innerGlow.hasKey(stringIDToTypeID("source"))) {
|
||||
var source = innerGlow.getEnumerationValue(stringIDToTypeID("source"));
|
||||
styles["内发光_来源"] = getInnerGlowSourceName(source);
|
||||
}
|
||||
}
|
||||
|
||||
if (innerGlow.hasKey(stringIDToTypeID("mode"))) {
|
||||
var modeID = innerGlow.getEnumerationValue(stringIDToTypeID("mode"));
|
||||
styles["内发光_混合模式"] = getBlendModeName(modeID);
|
||||
}
|
||||
|
||||
if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
|
||||
styles["内发光_大小"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
|
||||
}
|
||||
if (innerGlow.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["内发光_颜色"] = colorDescToHex(innerGlow.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
// if (innerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
|
||||
// var tech = innerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
|
||||
// styles["内发光_技巧"] = getInnerGlowTechniqueName(tech);
|
||||
// }
|
||||
if (innerGlow.hasKey(stringIDToTypeID("source"))) {
|
||||
var source = innerGlow.getEnumerationValue(stringIDToTypeID("source"));
|
||||
styles["内发光_来源"] = getInnerGlowSourceName(source);
|
||||
}
|
||||
// if (innerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
|
||||
// styles["内发光_阻塞"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
|
||||
// }
|
||||
// if (innerGlow.hasKey(stringIDToTypeID("blur"))) {
|
||||
// styles["内发光_模糊"] = innerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// ========= 斜面和浮雕 =========
|
||||
// ---- 斜面和浮雕 ----
|
||||
if (effects.hasKey(stringIDToTypeID("bevelEmboss"))) {
|
||||
var bevel = effects.getObjectValue(stringIDToTypeID("bevelEmboss"));
|
||||
styles["斜面_启用"] = bevel.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (styles["斜面_启用"]) {
|
||||
styles["斜面_样式"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("style")));
|
||||
styles["斜面_方法"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("technique")));
|
||||
styles["斜面_深度"] = bevel.getDouble(stringIDToTypeID("strength")) + "%";
|
||||
styles["斜面_方向"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("direction")));
|
||||
styles["斜面_大小"] = bevel.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
styles["斜面_软化"] = bevel.getUnitDoubleValue(stringIDToTypeID("soften")) + " 像素";
|
||||
styles["斜面_使用全局光"] = bevel.getBoolean(stringIDToTypeID("useGlobalAngle"));
|
||||
styles["斜面_角度"] = bevel.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
|
||||
if (bevel.hasKey(stringIDToTypeID("enabled"))) {
|
||||
var enabled = bevel.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (enabled) {
|
||||
styles["斜面_样式"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("style")));
|
||||
styles["斜面_方法"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("technique")));
|
||||
styles["斜面_深度"] = bevel.getDouble(stringIDToTypeID("strength")) + "%";
|
||||
styles["斜面_方向"] = typeIDToStringID(bevel.getEnumerationValue(stringIDToTypeID("direction")));
|
||||
styles["斜面_大小"] = bevel.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
styles["斜面_软化"] = bevel.getUnitDoubleValue(stringIDToTypeID("soften")) + " 像素";
|
||||
styles["斜面_使用全局光"] = bevel.getBoolean(stringIDToTypeID("useGlobalAngle"));
|
||||
styles["斜面_角度"] = bevel.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
|
||||
|
||||
if (bevel.hasKey(stringIDToTypeID("highlightColor"))) {
|
||||
var color = bevel.getObjectValue(stringIDToTypeID("highlightColor"));
|
||||
styles["斜面_高光颜色"] = colorToHex(color);
|
||||
}
|
||||
if (bevel.hasKey(stringIDToTypeID("highlightMode"))) {
|
||||
var mode = bevel.getEnumerationValue(stringIDToTypeID("highlightMode"));
|
||||
styles["斜面_高光模式"] = typeIDToStringID(mode);
|
||||
if (bevel.hasKey(stringIDToTypeID("highlightColor"))) {
|
||||
var color = bevel.getObjectValue(stringIDToTypeID("highlightColor"));
|
||||
styles["斜面_高光颜色"] = colorToHex(color);
|
||||
}
|
||||
if (bevel.hasKey(stringIDToTypeID("highlightMode"))) {
|
||||
var mode = bevel.getEnumerationValue(stringIDToTypeID("highlightMode"));
|
||||
styles["斜面_高光模式"] = typeIDToStringID(mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========= 光泽(Satin) =========
|
||||
if (effects.hasKey(stringIDToTypeID("satin"))) {
|
||||
var satin = effects.getObjectValue(stringIDToTypeID("satin"));
|
||||
styles["光泽_启用"] = satin.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (styles["光泽_启用"]) {
|
||||
styles["光泽_混合模式"] = typeIDToStringID(satin.getEnumerationValue(stringIDToTypeID("mode")));
|
||||
styles["光泽_不透明度"] = satin.getInteger(stringIDToTypeID("opacity")) + "%";
|
||||
styles["光泽_角度"] = satin.getInteger(stringIDToTypeID("localLightingAngle")) + "°";
|
||||
styles["光泽_距离"] = satin.getUnitDoubleValue(stringIDToTypeID("distance")) + " 像素";
|
||||
styles["光泽_大小"] = satin.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
}
|
||||
}
|
||||
|
||||
// ============ 外发光 ===============
|
||||
// ---- 外发光 ----
|
||||
if (effects.hasKey(stringIDToTypeID("outerGlow"))) {
|
||||
var outerGlow = effects.getObjectValue(stringIDToTypeID("outerGlow"));
|
||||
styles["外发光_启用"] = outerGlow.getBoolean(stringIDToTypeID("enabled"));
|
||||
// 遍历输出所有 key 名称,方便调试
|
||||
// var keys = [];
|
||||
// for (var i = 0; i < outerGlow.count; i++) {
|
||||
// var key = outerGlow.getKey(i);
|
||||
// var keyName = typeIDToStringID(key);
|
||||
// keys.push(keyName);
|
||||
// }
|
||||
|
||||
if (styles["外发光_启用"]) {
|
||||
if (outerGlow.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["外发光_不透明度"] = Math.round(outerGlow.getUnitDoubleValue(stringIDToTypeID("opacity")) ) + "%";
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["外发光_颜色"] = colorDescToHex(outerGlow.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
|
||||
var techniqueEnum = outerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
|
||||
var techniqueStr = typeIDToStringID(techniqueEnum);
|
||||
|
||||
styles["外发光_图素方法"] = getOuterGlowTechniqueName(techniqueStr); // 例如返回"精确"
|
||||
}
|
||||
|
||||
if (outerGlow.hasKey(stringIDToTypeID("blur"))) {
|
||||
styles["外发光_大小"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
|
||||
styles["外发光_阻塞"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
|
||||
}
|
||||
try{
|
||||
if (outerGlow.hasKey(stringIDToTypeID("transferSpec"))) {
|
||||
var transferSpec = outerGlow.getObjectValue(stringIDToTypeID("transferSpec")); // 先获取对象
|
||||
var nameID = stringIDToTypeID("name");
|
||||
if (transferSpec.hasKey(nameID)) {
|
||||
styles["外发光_等高线"] = transferSpec.getString(nameID);
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("enabled"))) {
|
||||
var enabled = outerGlow.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (styles["外发光_启用"]) {
|
||||
if (outerGlow.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["外发光_不透明度"] = Math.round(outerGlow.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["外发光_颜色"] = colorDescToHex(outerGlow.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("glowTechnique"))) {
|
||||
var techEnum = outerGlow.getEnumerationValue(stringIDToTypeID("glowTechnique"));
|
||||
styles["外发光_图素方法"] = getOuterGlowTechniqueName(typeIDToStringID(techEnum));
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("blur"))) {
|
||||
styles["外发光_大小"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("blur")) + " 像素";
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("chokeMatte"))) {
|
||||
styles["外发光_阻塞"] = outerGlow.getUnitDoubleValue(stringIDToTypeID("chokeMatte")) + " 像素";
|
||||
}
|
||||
if (outerGlow.hasKey(stringIDToTypeID("mode"))) {
|
||||
styles["外发光_混合模式"] = getBlendModeName(outerGlow.getEnumerationValue(stringIDToTypeID("mode")));
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
// alert("外发光_等高线: " + e.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (outerGlow.hasKey(stringIDToTypeID("mode"))) {
|
||||
var blendMode = outerGlow.getEnumerationValue(stringIDToTypeID("mode"));
|
||||
styles["外发光_混合模式"] = getBlendModeName(blendMode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 光泽(Satin) ----
|
||||
if (effects.hasKey(stringIDToTypeID("satin"))) {
|
||||
var satin = effects.getObjectValue(stringIDToTypeID("satin"));
|
||||
if (satin.hasKey(stringIDToTypeID("enabled"))) {
|
||||
var enabled = satin.getBoolean(stringIDToTypeID("enabled"));
|
||||
if (enabled) {
|
||||
if (satin.hasKey(stringIDToTypeID("opacity"))) {
|
||||
styles["光泽_不透明度"] = Math.round(satin.getUnitDoubleValue(stringIDToTypeID("opacity"))) + "%";
|
||||
}
|
||||
if (satin.hasKey(stringIDToTypeID("color"))) {
|
||||
styles["光泽_颜色"] = colorDescToHex(satin.getObjectValue(stringIDToTypeID("color")));
|
||||
}
|
||||
if (satin.hasKey(stringIDToTypeID("mode"))) {
|
||||
styles["光泽_混合模式"] = getBlendModeName(satin.getEnumerationValue(stringIDToTypeID("mode")));
|
||||
}
|
||||
if (satin.hasKey(stringIDToTypeID("angle"))) {
|
||||
styles["光泽_角度"] = satin.getUnitDoubleValue(stringIDToTypeID("angle")) + "°";
|
||||
}
|
||||
if (satin.hasKey(stringIDToTypeID("distance"))) {
|
||||
styles["光泽_距离"] = satin.getUnitDoubleValue(stringIDToTypeID("distance")) + " 像素";
|
||||
}
|
||||
if (satin.hasKey(stringIDToTypeID("size"))) {
|
||||
styles["光泽_大小"] = satin.getUnitDoubleValue(stringIDToTypeID("size")) + " 像素";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasOwnProperties(styles) ? styles : null;
|
||||
|
||||
} catch (e) {
|
||||
// alert("读取图层样式异常: " + e.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -936,5 +919,10 @@ function hasOwnProperties(obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function isEmptyObject(obj) {
|
||||
for (var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user