|
楼主 |
发表于 2011-1-6 23:00:37
|
显示全部楼层
本帖最后由 ka777 于 2011-1-7 11:05 编辑
Photoshop本身没有提供统计图层数量的功能, 需要自己编写脚本实现.
发一个我写的脚本, 需要的同学把下面这些代码复制到"记事本"里, 再保存成后缀为".jsx"的文件, 例如: "统计图层数.jsx"
进入Photoshop, 打开需要统计图层数量的文件, 然后点击菜单: 文件 -> 脚本 -> 浏览, 选中你刚才保存的脚本即可看到统计结果;
Photoshop执行脚本速度很慢, 如果你的图层很多, 需要等待一些时间- // Photoshop 图层数统计脚本
- // by Ka777
- #target photoshop
- app.bringToFront();
- function main() {
- var LayerCount = new Object();
-
- LayerCount.All = 0;
- LayerCount.Visible = 0;
- LayerCount.Hide = 0;
- LayerCount.topToBottom = false;
- GetLayerCount( activeDocument, LayerCount );
- alert (' 总 共: ' + LayerCount.All + ' 层\n 可见层: ' + LayerCount.Visible + ' 层\n 隐藏层: ' +LayerCount.Hide + ' 层', '图层数统计完毕' );
- }
- function GetLayerCount( ref, LayerCount )
- {
- for ( var i = 0; i < ref.layers.length; i++ )
- {
- if ( ref.layers[i].typename == 'LayerSet' )
- {
- GetLayerCount( ref.layers[i], LayerCount );
- }
- else
- {
- LayerCount.All ++;
- if( ref.layers[i].visible )
- LayerCount.Visible ++;
- else
- LayerCount.Hide ++;
- }
- }
- }
- function isCorrectVersion() {
- if (parseInt(version, 10) >= 9) {
- return true;
- }
- else {
- alert('This script requires Adobe Photoshop CS2 or higher.', 'Wrong Version', false);
- return false;
- }
- }
- function isOpenDocs() {
- if (documents.length) {
- return true;
- }
- else {
- alert('There are no documents open.', 'No Documents Open', false);
- return false;
- }
- }
- function showError(err) {
- if (confirm('An unknown error has occurred.\n' +
- 'Would you like to see more information?', true, 'Unknown Error')) {
- alert(err + ': on line ' + err.line, 'Script Error', true);
- }
- }
- if (isCorrectVersion() && isOpenDocs()) {
- try {
- // suspend history for CS3 (v10) or higher
- if (parseInt(version, 10) >= 10) {
- activeDocument.suspendHistory('Rename Layers', 'main()');
- }
- // just run main for CS2 (v9)
- else {
- main();
- }
- }
- catch(e) {
- if (e.number != 8007) { // don't report error on user cancel
- showError(e);
- }
- }
- }
复制代码 |
|