Skip to content

Instantly share code, notes, and snippets.

@PixxxeL
Created March 26, 2025 09:26
Show Gist options
  • Select an option

  • Save PixxxeL/de6e07e6147cc4e798ad4c06d41694ab to your computer and use it in GitHub Desktop.

Select an option

Save PixxxeL/de6e07e6147cc4e798ad4c06d41694ab to your computer and use it in GitHub Desktop.
Print coordinates and dimensions of Photoshop's layers in the text file
#target photoshop
app.bringToFront()
const NL = '\r\n'
const doc = app.activeDocument
const file = new File('~/Downloads/layer-coordinates.txt')
file.open('w')
file.write('filepath: ' + doc.fullName + NL)
file.write('===' + NL)
function getLayerInfo(layer) {
const bounds = layer.bounds;
file.write('name: ' + layer.name + NL)
file.write('x: ' + bounds[0].value + NL)
file.write('y: ' + bounds[1].value + NL)
file.write('width: ' + (bounds[2].value - bounds[0].value) + NL)
file.write('height: ' + (bounds[3].value - bounds[1].value) + NL)
file.write('---' + NL)
if (layer.typename === 'LayerSet') {
for (var i = 0; i < layer.layers.length; i++) {
getLayerInfo(layer.layers[i]);
}
}
}
for (var i = 0; i < doc.layers.length; i++) {
getLayerInfo(doc.layers[i]);
}
file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment