• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to change a layers opacity?

New Here ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

Hi there,

I am new to the whole concept of photoshop cripting and am really struggling,  I wish to change the opacity of several layers, do I have to define the function first??

I would really appreciate it if someone could help!! realy struggling here

TOPICS
Actions and scripting

Views

783

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Guru ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

The opacity of a layer is changed by setting the layer object's opacity property

app.activeDocument.activeLayer.opacity = 50;

You can only set the opacity one layer at a time so if you want to change several layers you will need to change them one at a time.

You do not have to have a function or other control structures like a loop but depending on what else you want to do or coding style them could be helpful.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

so I just have it in the wrong place? sorry.. im really stuck here  

                    app.activeDocument=doc1;

                    doc1.resizeImage(posterWidth,posterHeight/4);

                    doc1.selection.selectAll();

                    doc1.selection.copy();

                    doc1.selection.deselect();

                    app.activeDocument=newDoc;

                    newDoc.artLayers.add();

                    newDoc.paste();

                    newDoc.activeLayer.translate(0,-posterHeight/2+posterHeight/8);

                    app.activeDocument=newDoc;

                    newDoc.selection.selectAll();

                    newDoc.selection.opacity = 17;

                    newDoc.selection.deselect();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

Not yet the correct syntax.

Try something like this (look to compare):

var doc1 = app.activeDocument;

var h = doc1.height ;

var w = doc1.width;

doc1.resizeImage (w, h/4);

doc1.selection.selectAll();

doc1.selection.copy();

doc1.selection.deselect(); // do never save your doc1 at this time !!!

var newDoc = app.documents.add ();

newDoc.paste();

newDoc.activeLayer.translate (0, -h/2+h/8);

newDoc.activeLayer.opacity = 17;

app.refresh();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 31, 2013 Oct 31, 2013

Copy link to clipboard

Copied

LATEST

You want to change a layer's opacity. You do that by changing the layer's opacity property. Your code tries to change a selection property. Because selection does not have an opacity property what that line really does is create a new property for selection and sets it to 17. There is no error but it doesn't do what you want.

If you are just starting you may want to look at the Photoshop JavaScript Reference for you version of Photoshop. It lists the object, properties, and methods for Photoshop.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines