Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Photoshop Javascript - Resize multiple layers

I have a script on Photoshop that allows me to resize a layer to the image bounds while maintaining the proportions.
The code is the seguent:

    var Document = app.activeDocument;
    var BND = app.activeDocument.activeLayer.bounds;
    var IHeight = (BND[3] - BND[1]);
    var IWidth = (BND[2] - BND[0]);
    if (IWidth >= IHeight) {
        Document.activeLayer.resize ((Document.width / IWidth * 100), (Document.width / IWidth * 100), AnchorPosition.MIDDLECENTER);
        }
    else {
        Document.activeLayer.resize ((Document.height / IHeight * 100), (Document.height / IHeight * 100), AnchorPosition.MIDDLECENTER);
        }

The problem is that it only resizes the active layer.
I'm trying to integrate the seguent piece of code that selects all the layers:

    var NAD = new ActionDescriptor ();
    var NAR = new ActionReference ();
    NAR.putEnumerated (charIDToTypeID ("Lyr "), charIDToTypeID ("Ordn"), charIDToTypeID ("Trgt"));
    NAD.putReference (charIDToTypeID ("null"), NAR);
    executeAction (stringIDToTypeID ("selectAllLayers"), NAD, DialogModes.NO);

What I want to do is resize all the layers together so that they can keep the same aspect ratio between each other, so i can't resize with a loop or the proportions would be lost by transforming all layers to the same size as the canvas.
Do you have any ideas how this could be done?
I have already tried to replace activeLayer with layers or artLayers, but I get "Error 1302: No such element" and I don't know how to address the problem.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!