0
Detect transparent pixels
Engaged
,
/t5/photoshop-ecosystem-discussions/detect-transparent-pixels/td-p/11730714
Jan 06, 2021
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Have something to add?
Join the conversation
Explore related tutorials & articles

