Skip to main content
Participant
September 18, 2024
Answered

resizing several or all items to the same size

  • September 18, 2024
  • 1 reply
  • 241 views

Hello friends

I'm creating a collage out of several images of different sizes. I want to resize all the images/layers to the same height. Is there a way I can grab all 16 images of different sizes and resize them all to, for example, 1000px tall?

 

Thanks for any tips!

John

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

@JohnnyJomp – A few quick hacks to an old script:

 

// https://forums.adobe.com/message/10377562#10377562

#target photoshop

app.activeDocument.suspendHistory("Proportionally Resize Height of Selected Layers...", "main()");

function main() {

     preferences.rulerUnits = Units.PIXELS
     function sTT(v) {
          return stringIDToTypeID(v)
     }

     (ref = new ActionReference()).putEnumerated
          (sTT('document'), sTT('ordinal'), sTT('targetEnum'))
    len = executeActionGet(ref).getInteger(sTT('numberOfLayers'))
    
    // Loop the input prompt until a number is entered
    var newHeightInput;
    while (isNaN(newHeightInput = prompt("Enter a new height in pixels for the selected layers:", "1000")));
    // Convert decimal input to integer
    var newHeight = parseInt(newHeightInput);
    // Test if Cancel returns null, then do nothing
    if (newHeight === null) { return }
    // Test if an empty string is returned, then do nothing 
    if (newHeight === "") { return }

     for (i = 1; i <= len;) {
          (ref = new ActionReference()).putIndex(sTT('layer'), i++)
          if (typeIDToStringID((dsc = executeActionGet(ref)).getEnumerationValue(sTT(lS = 'layerSection'))) == lS + 'Content') {
               (lst = new ActionList()).putReference(ref), dsc.putList(sTT('null'), lst)
               if (!dsc.getBoolean(sTT('visible'))) {
                    executeAction(sTT('show'), dsc, DialogModes.NO)
               }
               (ref = new ActionReference()).putIndex(sTT('layer'), i - 1);
               (dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
               executeAction(sTT('select'), dsc, DialogModes.NO)
               with (activeDocument.activeLayer) {
                    resize(s = newHeight / ((b = bounds)[3] - b[1]) * 100, s) 
               }
          }
     }
}

 

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

1 reply

Stephen Marsh
Community Expert
Stephen MarshCommunity ExpertCorrect answer
Community Expert
September 18, 2024

@JohnnyJomp – A few quick hacks to an old script:

 

// https://forums.adobe.com/message/10377562#10377562

#target photoshop

app.activeDocument.suspendHistory("Proportionally Resize Height of Selected Layers...", "main()");

function main() {

     preferences.rulerUnits = Units.PIXELS
     function sTT(v) {
          return stringIDToTypeID(v)
     }

     (ref = new ActionReference()).putEnumerated
          (sTT('document'), sTT('ordinal'), sTT('targetEnum'))
    len = executeActionGet(ref).getInteger(sTT('numberOfLayers'))
    
    // Loop the input prompt until a number is entered
    var newHeightInput;
    while (isNaN(newHeightInput = prompt("Enter a new height in pixels for the selected layers:", "1000")));
    // Convert decimal input to integer
    var newHeight = parseInt(newHeightInput);
    // Test if Cancel returns null, then do nothing
    if (newHeight === null) { return }
    // Test if an empty string is returned, then do nothing 
    if (newHeight === "") { return }

     for (i = 1; i <= len;) {
          (ref = new ActionReference()).putIndex(sTT('layer'), i++)
          if (typeIDToStringID((dsc = executeActionGet(ref)).getEnumerationValue(sTT(lS = 'layerSection'))) == lS + 'Content') {
               (lst = new ActionList()).putReference(ref), dsc.putList(sTT('null'), lst)
               if (!dsc.getBoolean(sTT('visible'))) {
                    executeAction(sTT('show'), dsc, DialogModes.NO)
               }
               (ref = new ActionReference()).putIndex(sTT('layer'), i - 1);
               (dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
               executeAction(sTT('select'), dsc, DialogModes.NO)
               with (activeDocument.activeLayer) {
                    resize(s = newHeight / ((b = bounds)[3] - b[1]) * 100, s) 
               }
          }
     }
}

 

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