Skip to main content
Mr. Mendelli
Known Participant
September 21, 2019
Answered

Is it possible to get the original dimensions of a smart object?

  • September 21, 2019
  • 3 replies
  • 1880 views

I have created a large collection of images with various smart objects such as logos. I use high-resolution images and downscale them as needed, I now have to adjust some of these projects and they will now be in a larger resolution and aspect ratio. I want to know if it's possible to get the original dimenstions of these smart objects so that I don't over-scale them when I make the projects in a higher resolution.

This topic has been closed for replies.
Correct answer Stephen Marsh

A very simple script to show the bounds info of the current active smart object layer, presuming a single layer in the opened smart object (manually target the smart object layer first):

 

 

 

#target photoshop
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
var activeBounds = app.activeDocument.activeLayer.bounds;
app.activeDocument.close();
alert(activeBounds);

 

 

 

This version is a little more refined than the previous:

 

 

#target photoshop
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
var activeLayer = activeDocument.activeLayer;
var layerHeight = activeLayer.bounds[2]-activeLayer.bounds[0];
var layerWidth = activeLayer.bounds[3]-activeLayer.bounds[1];
var alertText = "Smart object size = " + layerHeight + " x " + layerWidth
app.activeDocument.close();
alert(alertText);

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

3 replies

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
September 21, 2019

A very simple script to show the bounds info of the current active smart object layer, presuming a single layer in the opened smart object (manually target the smart object layer first):

 

 

 

#target photoshop
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
var activeBounds = app.activeDocument.activeLayer.bounds;
app.activeDocument.close();
alert(activeBounds);

 

 

 

This version is a little more refined than the previous:

 

 

#target photoshop
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
var activeLayer = activeDocument.activeLayer;
var layerHeight = activeLayer.bounds[2]-activeLayer.bounds[0];
var layerWidth = activeLayer.bounds[3]-activeLayer.bounds[1];
var alertText = "Smart object size = " + layerHeight + " x " + layerWidth
app.activeDocument.close();
alert(alertText);

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

Mr. Mendelli
Known Participant
September 22, 2019

Very helpful, iss it possible to get the window to display all of the layer names and corrisponding sizes at once? E.G.:

 

Layer 1: 128 x 72

Layer 2: 56 x 56

Background: 223 x 127

Mr. Mendelli
Known Participant
September 22, 2019
Sure it’s possible, however not probable at my current scripting level.
That's ok, thanks for the help anyways.
Bojan Živković11378569
Community Expert
Community Expert
September 21, 2019

Do you have Smart Object layers placed in Photoshop using File > Place Embedded? Just double click to enter editing mode and look at status bar or from Properties panel or from Info panel or even go to Image > Image Size. It will be slow for multiple layers but at least you will have working solution without third party.

 

By the way, it will work with any Smart Object layer but... if you have resampled original file before converting to Smart Object it will be available at that dimensions not at original which are gone for good in that case.

Mr. Mendelli
Known Participant
September 21, 2019
No but it's good to know, thank you.
barbara_a7746676
Community Expert
Community Expert
September 21, 2019
Mr. Mendelli
Known Participant
September 21, 2019

Seems promising, but I've hit an error on line 71 with it (for (var i = 0; i < set.layers.length; i++){). I'm not well-versed inJavaScript and I'm using this with CS6. Do you have a solution or suggestion or should I just open a new question?

barbara_a7746676
Community Expert
Community Expert
September 21, 2019
You could try contacting the person who originally wrote the script.