|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function exportSelectedLayerOnly() { |
|
|
|
function getAllArtLayers (document, layerCollection){ |
|
for (var i = 0; i < document.layers.length; i++){ |
|
var currentLayer = document.layers[i]; |
|
if (currentLayer.typename === "ArtLayer"){ |
|
layerCollection.push(currentLayer); |
|
} else { |
|
getAllArtLayers(currentLayer, layerCollection); |
|
} |
|
} |
|
return layerCollection; |
|
} |
|
|
|
var allLayers = [] |
|
allLayers = getAllArtLayers(app.activeDocument, allLayers); |
|
|
|
|
|
layerStates = [] |
|
for (var i = 0; i < allLayers.length; i++) { |
|
layerStates.push(allLayers[i].visible) |
|
allLayers[i].visible = allLayers[i] == app.activeDocument.activeLayer |
|
} |
|
|
|
|
|
app.activeDocument.saveToOE("JPG"); |
|
|
|
|
|
for (var i = 0; i < allLayers.length; i++) { |
|
allLayers[i].visible = layerStates[i] |
|
} |
|
} |
|
|
|
|
|
function createMaskFromSelection() { |
|
if (app.activeDocument.selection === null) { |
|
app.echo("No selection!"); |
|
return; |
|
} |
|
|
|
|
|
newLayer = app.activeDocument.artLayers.add(); |
|
newLayer.name = "TempMaskLayer"; |
|
|
|
|
|
app.activeDocument.selection.invert(); |
|
color = new SolidColor(); |
|
color.rgb.red = 0 |
|
color.rgb.green = 0 |
|
color.rgb.blue = 0 |
|
app.activeDocument.selection.fill(color); |
|
|
|
|
|
color.rgb.red = 255 |
|
color.rgb.green = 255 |
|
color.rgb.blue = 255 |
|
app.activeDocument.selection.invert(); |
|
app.activeDocument.selection.fill(color); |
|
} |
|
|
|
function selectionExists() { |
|
|
|
|
|
app.echoToOE(app.activeDocument.selection.bounds != null); |
|
} |
|
|
|
function getActiveDocumentSize() { |
|
app.echoToOE(app.activeDocument.width + "," + app.activeDocument.height); |
|
} |