How can I capture a smart object's original dimension via scripts?
The Setting
I have a document with a canvas size of 1920x1080 and a large number of layers. Each layer is a smart object which I've placed by dragging and dropping the contents of a folder onto the canvas. No two layers have the same dimensions. Some of the smart objects are larger than the canvas and photoshop is automatically shrinking them down to fit.
The Goal
I want all my smart objects to be their original dimensions.
I want to avoid going to each object, transforming, clicking the "link dimensions" button, manually typing "100%", and placing the transform.
The Problem
First, I tried creating an action to select the layer > transform width and height to 100% > select next layer. Next, I tried creating a script to go through each layer and resize() to 100%. Both attempts were foiled by the same problem, the resize function is relative to the object's current dimensions.
for example
When creating an action, I recorded my actions and by manually typing in "100%" for the smart object transform. The smart object resized to its original dimensions. Perfect, this is what I want. However, when I drilled into the action it had actually resized 405%. I typed in "100%" but it recorded "405%" making this action unusable unless the layers were all the same exact size.
My Questions
How can I capture a smart object's original dimensions?
Is there a better way to go about this?
---------
Cheers!
---------
My Current Script
var doc = app.activeDocument;
var allLayers = [];
var allLayers = collectAllLayers(doc, allLayers);
function collectAllLayers (doc, allLayers){
for (var m = 0; m < doc.layers.length; m++){
var theLayer = doc.layers
; if (theLayer.typename === "ArtLayer"){
allLayers.push(theLayer);
}else{
collectAllLayers(theLayer, allLayers);
}
}
return allLayers;
}
for(i = (allLayers.length-1); i >= 0; i--){
//resize smart object to original dimension
};
