Подсчитать количество слоев в фотошопе

9451
Mayo

Есть ли способ узнать количество слоев в .psd?

У меня есть .psds, которые ужасно замедляются. Есть 20-30 слоев и неизвестное количество слоев. 1000? 5,0000? Я не знаю.

Причина этого заключается в том, чтобы начать выяснять, в какой момент фотошоп начинает задыхаться. Если у меня есть фотошоп, использующий 90 доступной памяти, он быстро увеличивает 11 ГБ, замедляя мой блок для других целей, и если я оставляю его на 50% (7 ГБ), возникает пауза, когда я дублирую даже самый маленький слой (скажем, галочка, которая идет в флажок).

2

6 ответов на вопрос

5
joojaa

You could use python psdtools package for this:

from __future__ import print_function from psd_tools import PSDImage psd = PSDImage.load('my_image.psd') print("file has {} layers".format(len(psd.layers))) 
У меня проблемы с загрузкой этого пакета на работе. Я не получаю доступ администратора для загрузки psdtools (или 7-zip). Проверим это дома. Mayo 8 лет назад 0
1
AAGD

Just a thought: If you're on a Mac, the Finder's file info (cmd-i) might be helpful, as it lists all names of the layers without even opening the file . You could copy this into a text editor with line numbering and replace all commas with linefeeds. The line numbering would reveal the number of layers (I havn't tested what happens with commas in layer names).

EDIT:

One more finding: Gimp has an info panel that shows the layer count for a psd file (Menu: Image > Image Properties)

gimp psd layercount

Интересно. К сожалению, я не на Mac. Я видел это, когда гуглил. Я не видел этот вариант для ПК. Mayo 8 лет назад 0
возможно это помогает, на первый взгляд это не выглядело специфичным для Mac: http://blog.kyletunneyphotography.com/counting-layers-in-photoshop/ AAGD 8 лет назад 0
Спасибо. Я видел это во время поиска (после публикации) и вижу, что Rishab Ag скопировал и вставил текст с этого сайта. Попробую это. Mayo 8 лет назад 0
0
Rishab

Unfortunately there is no automatic feature to count the layer but here you can use this script-

var totalProgress = 0// I assume this is defined eleswhere but is needed for the scriptler function layerCounter(inObj) // recursive function to count layers { totalProgress+= inObj.artLayers.length; for( var i = 0; i < inObj.layerSets.length; i++) { totalProgress++; layerCounter(inObj.layerSets[i]); // recursive call to layerCounter } return totalProgress; } function getLayerCount(){ function getNumberLayers(){ var ref = new ActionReference(); ref.putProperty( charIDToTypeID("Prpr"), charIDToTypeID("NmbL") ) ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); return executeActionGet(ref).getInteger(charIDToTypeID("NmbL")); } function getLayerType(idx) { var ref = new ActionReference(); ref.putProperty( charIDToTypeID("Prpr"), stringIDToTypeID("layerSection")); ref.putIndex(charIDToTypeID( "Lyr " ), idx); return typeIDToStringID(executeActionGet(ref).getEnumerationValue(stringIDToTypeID('layerSection'))); }; var cnt = getNumberLayers(); var res = cnt; if(activeDocument.layers[activeDocument.layers.length-1].isBackgroundLayer){ var i = 0; //comment out line below to exclude background from count res++; }else{ var i = 1; }; for(i;i<cnt;i++){ var temp = getLayerType(i); if(temp == "layerSectionEnd") res--; //if(temp == '"layerSectionStart") res--;//uncomment to count just artLayers }; return res; }; function main() { var answer = confirm("Go through your file and count all the layers??"); if(answer) { var reporter1 = layerCounter(app.activeDocument); alert("Kyletunney.com - All done! Layer count = " + reporter1); } else { reporter2 = getLayerCount(); alert("Kyletunney.com - All done! Layer count = " + reporter2); } } main(); 

Save the script as .jsx

How to use the script?

  • Open up Photoshop with the file you wish to count
  • Click on ‘File’
  • Then ‘Scripts’
  • Now click ‘Browse’
  • Find the script you just saved and click Load
  • You will now be prompted with ‘Go through your file and count all the layers??‘ Click ‘Yes’
  • You will now be informed of the amount of layers in your file!
Я попробовал этот скрипт дважды. Это разбило Фотошоп оба раза. Может быть, это работает с файлом с 10 слоями. Но это не сработало для файла с сотнями. Или это тысячи? Mayo 8 лет назад 0
странно, что этот сценарий сообщает о 48 слоях в файле, который имеет 38 слоев .. :( SpaceDog 7 лет назад 0
0
JfgDev

Ok, this may sound silly simple (if you have Photoshop), but the easiest way is to open the document in Photoshop and click the New Layer button at the bottom of the layers panel. The new layer will automatically be named "Layer 450" or one more than the number of the layers currently in the document.

0
SpaceDog

Если вы используете Mac, запустите этот скрипт в редакторе скриптов:

tell application "Adobe Photoshop CC 2015.5" activate set theDOC to the current document tell theDOC set numberOfLayers to count of layers display dialog numberOfLayers as string end tell end tell 
0
Goosfraba

Сделайте следующее:

  1. В строке состояния в левом нижнем углу окна редактирования нажмите на стрелку вправо.

Editing windows with status bar: The right-pointing arrow is highlighted.

  1. В появившемся всплывающем меню выберите «Количество слоев».
  2. Прочитайте количество слоев в строке состояния.

The status bar reads: 108 layers, 18 groups

@FleetCommand, спасибо за демонстрацию того, как написать хороший ответ. fixer1234 7 лет назад 1
@ Бурги Да, я знаю, но я был немного удивлен сложным кодированием и прочим, а также решениями в 2 клика (компенсируется фотографиями, хотя) Goosfraba 7 лет назад 0

Похожие вопросы