Copy link to clipboard
Copied
Hi all,
In my document I have a lot of layers. Each layer has a different height measurement, I want them all to be 21cm high.
When I record the action to transform the height to 21cm, the action overrrides it into percentage, leaving all my layers scaled instead of 21cm high. The layers are cut outs that I pasted from different files so I can't 'image size them seperatly'. They are already pasted in my file and I just want a quick way to get them all 21cm high.
Thank you so much,
Sara
Copy link to clipboard
Copied
Are you proportionally scaling or distorting only the height to 21cm?
If you turn the layer into a smart object, then edit the smart object, you can use image size or fit image, which does work in px and not %.
Or you can duplicate the layer to a new file, resize or fit image, then drag or copy/paste it as a layer.
A custom script may be another workaround.
This script from @jazz-y will create a smart objects from the original top-level layers (perhaps work on a duplicate of your curren doc). Then each SO layer can have an action recorded to open the SO and resize the smart object using image size or fit image, saved and closed to updage the layer content in your layered file.
/* convert all top level layers and layer sets to smart objects AM CODE.jsx
by jazz-y (DmitryEgorov)
Smart Objects in separate layers
https://community.adobe.com/t5/photoshop/smart-objects-in-separate-layers/td-p/11137197
*/
#target photoshop
s2t = stringIDToTypeID;
t2s = typeIDToStringID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('hasBackgroundLayer'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'))
var indexFrom = executeActionGet(r).getBoolean(p) ? 0 : 1;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('numberOfLayers'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'))
var indexTo = executeActionGet(r).getInteger(p);
var layers = {}
parseLayerSets(indexFrom, indexTo, layers)
for (o in layers) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerKind'));
r.putIdentifier(s2t("layer"), layers[o].id);
var kind = executeActionGet(r).getInteger(p)
if (kind != 2 && kind != 5) {
(r = new ActionReference()).putIdentifier(s2t("layer"), layers[o].id);
(d = new ActionDescriptor()).putReference(s2t("null"), r);
executeAction(s2t("select"), d, DialogModes.NO)
try {
executeAction(s2t("newPlacedLayer"), undefined, DialogModes.NO);
} catch (e) {
alert(e)
}
}
}
function parseLayerSets(from, to, parentObj) {
for (var i = from; i <= to; i++) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerSection'));
r.putIndex(s2t("layer"), i)
var section = t2s(executeActionGet(r).getEnumerationValue(p))
if (section == 'layerSectionEnd') {
i = parseLayerSets(i + 1, to, parentObj[i] = {})
continue;
}
var properties = {};
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('layerID'));
r.putIndex(s2t("layer"), i);
properties.id = executeActionGet(r).getInteger(p);
if (section == 'layerSectionStart') {
for (o in properties) {
parentObj[o] = properties[o]
}
return i;
} else {
parentObj[i] = properties
}
}
}
Copy link to clipboard
Copied
You need to be careful recording Transform in Action. Size change will always be recorded as a relative side percentage change this is normally resizing. However the translate will be recorded in ruler units setting normally however when I set unite to CM if records as inches it may be due to the document resolution is set to PPI not PPC. The position is also recorded in ruler units. Angle of rotation in degrees and if you also warp in transform the transform step records many point in pixel values many points are recorded in Pixels not all will be displayed in the action step in the action palette. Transform is powerful and very complex. You need to read what is recorded to know how the step will work.
Copy link to clipboard
Copied
Thank you everybody, the conclusion is, there is no 'quick way' of doing this. By the time I put an action on all layers turning them into smart objects I might as well just do it manually and spend a bit more time on doing that. I don't know anything about script myself so I won't dive into that. Thank you for your replies, I'm surprised I can't be the only one just pasting things into a new document and wanted them the same height? I hope the they add a transform option that just allows this to be done in a quick way.
I probably should have transformed them 21cm before pasting them in the new file.. ah well..
Thank you for sharing your solutions.
Sara
Ps Yes I want them proportionally scaled to 21cm height.
Copy link to clipboard
Copied
If you are just tiling images I made a script for that in my package for populating templates. No template is required for pasting in tiled images. Images will be scale to for the tile side. If an Image has a different aspect ratio than the tile size the scaled image will be masked to the tile aspect ratio make it tile size. The image will look like a centered aspect ratio crop for the tile aspect ratio. Paste into is used not Place. The tiles document will be layer. So you will be able move masked image to adjust the virtual crop image composition.
Copy link to clipboard
Copied
Isn't "translate" the position of the layer?
All of your actions still have the width/height in %, which is the scale/size. That means the final will be relative to the original size of the layer and not an absolute figure (in the OPS case 21cm).
I'm also trying to figure this out and I can't get an action to scale the layer to an absolute (in my case 4cm). It's always a % regardless of the unit settings.
Copy link to clipboard
Copied
Sadly JJMack is no longer with us.
I'll take a look later. Photoshop likes pixels as that is the definitive base building block of an image.
Copy link to clipboard
Copied
Sorry to hear that.
Pixels would work as well. Based on my document size, I can work out how many pixels 4cm is, so that is no problem.
It just needs to be an absolute number rather than a relative one, as every layer has a slightly different starting size.
Copy link to clipboard
Copied
This is one of those things at is the same for scripts, it is using % and I don't believe that it can be overridden.
As previously written, converting a layer to a smart object then editing the SO one can then use fit image or image size commands.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now