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

checking each individual pixel of a layer for transparency

New Here ,
Feb 14, 2013 Feb 14, 2013

Copy link to clipboard

Copied

hi,

i'm very confused and challenged in understanding on how a photoshop script can

access step-by-step each indidual pixel of a given layer in order to check it's

transparency. means, I need to identify transparent pixels.

I especially need to check whether/which pixels are transparent. isn't this transparency coded

in the alpha value of a pixel? I have transparent pixels in my PSD file layer, but there is no

alpha channel displayed in photoshop, only the three R, G and B layers. how can this work?

thanks for any help.

best

stephen

TOPICS
Actions and scripting

Views

1.2K

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

correct answers 1 Correct answer

Valorous Hero , Feb 14, 2013 Feb 14, 2013

Testing each pixel would take forever.

You can do this though...

#target photoshop
main();
function main(){
selectTransparency();
try{
var sBnds = app.activeDocument.selection.bounds;
    }catch(e){
        alert("This layer does not have transparency");
        return;
        }
alert("Transparent pixels have been selected");
}

function selectTransparency() {
    var desc52 = new ActionDescriptor();
        var ref47 = new ActionReference();
        ref47.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fs

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Feb 14, 2013 Feb 14, 2013

Copy link to clipboard

Copied

LATEST

Testing each pixel would take forever.

You can do this though...

#target photoshop
main();
function main(){
selectTransparency();
try{
var sBnds = app.activeDocument.selection.bounds;
    }catch(e){
        alert("This layer does not have transparency");
        return;
        }
alert("Transparent pixels have been selected");
}

function selectTransparency() {
    var desc52 = new ActionDescriptor();
        var ref47 = new ActionReference();
        ref47.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
    desc52.putReference( charIDToTypeID('null'), ref47 );
        var ref48 = new ActionReference();
        ref48.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
    desc52.putReference( charIDToTypeID('T   '), ref48 );
    desc52.putBoolean( charIDToTypeID('Invr'), true );
    try{
    executeAction( charIDToTypeID('setd'), desc52, DialogModes.NO );
    }catch(e){}
};

This would be the same as :-

Selection - Load selection - Layer # Transparency with Invert selected.

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