-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave2xSizePNGByIndividualLayer.jsx
More file actions
39 lines (35 loc) · 1.07 KB
/
save2xSizePNGByIndividualLayer.jsx
File metadata and controls
39 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const folder = Folder.selectDialog("エクスポート先のフォルダを選択してください");
const document = app.activeDocument;
if(document && folder) {
const options = new ExportOptionsPNG24();
options.antiAliasing = true;
options.transparency = true;
options.artBoardClipping = true;
options.horizontalScale = 200;
options.verticalScale = 200;
const length = document.layers.length;
for(var i = 0; i < length; ++i) {
hideAllLayers();
var layer = document.layers[i];
layer.visible = true;
var file = new File(folder.fsName+"/"+layer.name+".png");
document.exportFile(file,ExportType.PNG24,options);
}
showAllLayers();
}
function hideAllLayers() {
forEach(document.layers, function(layer) {
layer.visible = false;
});
}
function showAllLayers() {
forEach(document.layers, function(layer) {
layer.visible = true;
});
}
function forEach(collection, fn) {
const length = collection.length;
for(var i = 0; i < length; ++i) {
fn(collection[i]);
}
}