Question
How to get the bounds of the exported png
- August 29, 2024
- 3 replies
- 1677 views
I use a script to export a layer as a png. This png does not contain transparent areas. how can I get the bounds of the png relative to the canvas.
function quickExportPng() {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
d.putString(stringIDToTypeID("fileType"), "png");
d.putInteger(stringIDToTypeID("quality"), 32);
d.putInteger(stringIDToTypeID("metadata"), 0);
d.putString(stringIDToTypeID("destFolder"), exportDir);
d.putBoolean(stringIDToTypeID("sRGB"), true);
d.putBoolean(stringIDToTypeID("openWindow"), false);
executeAction(stringIDToTypeID("exportSelectionAsFileTypePressed"), d, DialogModes.NO);
}
The red rectangle is the exported png content,The popup box is the bounds of the layer.

Press ctrl+T on this layer to display the actual content and position of this layer.

