I want to make a code giving me the corners of a rasterized layer/shape in Photoshop (uploaded an image for sample). My code is working but only for boxes/rectangles. But when an image/shape is slanted, my code gives me the wrong coordinates. I think because when an image is slanted, it detects a lot of corners in Photoshop.
I already tried this code:
var doc = app.activeDocument;
var selectedLayer = doc.activeLayer;
if (selectedLayer.kind == LayerKind.NORMAL) {
var bounds = selectedLayer.bounds;
var topLeft = [bounds[0].value, bounds[1].value];
var topRight = [bounds[2].value, bounds[1].value];
var bottomLeft = [bounds[0].value, bounds[3].value];
var bottomRight = [bounds[2].value, bounds[3].value];
alert("Top Left: " + topLeft + "\n" +
"Top Right: " + topRight + "\n" +
"Bottom Left: " + bottomLeft + "\n" +
"Bottom Right: " + bottomRight);
} else {
alert("Please select a rasterized image.");
}
What did I do wrong or what's lacking in my code to detect just the corners of the raster image?