Article View: adobe.photoshop.scripting
Article #81Opacity
From: 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!
Technical Details
Message-ID:
<59b8808e.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f5839,3efd978cef8ed09a,start X-Google-Attributes: gidf5839,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Kin2001@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.photoshop.scripting Subject: Opacity Message-ID: <59b8808e.-1@webcrossing.la2eafNXanI> Date: Fri, 3 Apr 2009 09:02:52 -0700 Lines: 46 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit