Thread View: adobe.photoshop.scripting
2 messages
2 total messages
Started by Kin2001
Fri, 03 Apr 2009 16:02
Opacity
Author: Kin2001
Date: Fri, 03 Apr 2009 16:02
Date: Fri, 03 Apr 2009 16:02
44 lines
1948 bytes
1948 bytes
Hi All,
I am new to scripting and I am trying to get the logic to change the opacity of a layer. Here's what I have so far.
//This is just a test script
#target photoshop
//bring application forward for double-click event
app.bringToFront();
//ensure that at least one document is open
if (!documents.length){
alert ('There are no documents open');
//if no document is open it will automatically create a new document once the user clicks ok
app.preferences.rulerUnits = Units.PIXELS
var docCount=documents.length
if (docCount==00
documents.add(1920,1080)
//create a new art layer at the beginning of the current document
var layerRef = app.activeDocument.artLayers.add()
layerRef.name = "Background"
layerRef.blendMode = BlendMode.NORMAL
//Select all so we can apply a fill to the selection
app.activeDocument.selection.selectAll
//create a color to used with the fill command
var colorRef = new SolidColor
colorRef.rgb.red = 0
colorRef.rgb.green = 0
colorRef.rgb.blue = 0
//Now apply fill to current selection
app.activeDocument.selection.fill(colorRef)
function changeOpacity(Background,opacity){
var object = imageObject.Style
object.opacity = (opacity/50);
object.filter = "alpha (opacity = " + opacity + + "(";
I know this is simple but I can't seem to figure it out.
Thank You!
Re: Opacity
Author: Paul_R
Date: Fri, 03 Apr 2009 16:52
Date: Fri, 03 Apr 2009 16:52
59 lines
1606 bytes
1606 bytes
Something like this... //This is just a test script #target photoshop //bring application forward for double-click event app.bringToFront(); var current_units = preferences.rulerUnits; app.preferences.rulerUnits = Units.PIXELS documents.add(1920,1080) //create a new art layer at the beginning of the current document var layerRef = app.activeDocument.artLayers.add() layerRef.name = "Background2" layerRef.blendMode = BlendMode.NORMAL //Set opacity of new layer layerRef.opacity=60; //Select all so we can apply a fill to the selection app.activeDocument.selection.selectAll //create a color to used with the fill command var colorRef = new SolidColor colorRef.rgb.red = 0 colorRef.rgb.green = 0 colorRef.rgb.blue = 0 //Now apply fill to current selection app.activeDocument.selection.fill(colorRef); app.activeDocument.selection.deselect(); preferences.rulerUnits = current_units;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads