Detect transparent pixels

New Here ,
Jan 06, 2021

Copy link to clipboard

Copied

I'm trying to discover a way of detecting transparent pixels. More over if an image is on a transparent background. Looking at the four corner pixels will be sufficient.

 

Only I don't think there's a way to detect RGBA as if the code below is run on a transparent pixels it throws an General Photoshop 8800 error. Any ideas? Apart from a try/catch and or trying to copy paste said pixels.

 

  // Add a Color Sampler at a given x and y coordinate in the image.
  var pointSample = app.activeDocument.colorSamplers.add([(x),(y)]);

  // Obtain array of RGB values.
  var rgb = [
  pointSample.color.rgb.red,
  pointSample.color.rgb.green,
  pointSample.color.rgb.blue
 ];

 

TOPICS
Actions and scripting, Windows

Views

32

Likes

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

Detect transparent pixels

New Here ,
Jan 06, 2021

Copy link to clipboard

Copied

I'm trying to discover a way of detecting transparent pixels. More over if an image is on a transparent background. Looking at the four corner pixels will be sufficient.

 

Only I don't think there's a way to detect RGBA as if the code below is run on a transparent pixels it throws an General Photoshop 8800 error. Any ideas? Apart from a try/catch and or trying to copy paste said pixels.

 

  // Add a Color Sampler at a given x and y coordinate in the image.
  var pointSample = app.activeDocument.colorSamplers.add([(x),(y)]);

  // Obtain array of RGB values.
  var rgb = [
  pointSample.color.rgb.red,
  pointSample.color.rgb.green,
  pointSample.color.rgb.blue
 ];

 

TOPICS
Actions and scripting, Windows

Views

33

Likes

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
Jan 06, 2021 0

Have something to add?

Join the conversation