Skip to main content
Known Participant
September 14, 2019
Answered

How to? Resizing an image using the transform tool to a specific pixel-size...........in an action.

  • September 14, 2019
  • 1 reply
  • 672 views

I have a template in which I want to place several images. All these images have a different pixel-size and I want them all to be resized to 1080 pixels wide.

When I make an action using the Transform tool it records that action with a percentage. For example, when I place an image which is 2160 pixels wide and I record the action so that the image is transformed to 1080 pixels wide, the action records that the transformation is done by 50%.

But when I place a second image (say 3000 pixels wide) and I run the action, the image gets transformed to 1500 pixels wide (50%), but that's not what I want, I want that second image to be 1080 pixels wide.

So how can I make the action record a transformation to 1080 pixels wide in stead of resizing it to 50% ?

Thanks in advance for your help.

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

A scripted solution:

 

#target photoshop
(function (){
    var startRulerUnits = app.preferences.rulerUnits;  
    app.preferences.rulerUnits = Units.PIXELS;  
    var bounds = activeDocument.activeLayer.bounds;  
    var width = bounds[2].value - bounds[0].value;
    var newSize = (100 / width) * 300;  // 300px
    activeDocument.activeLayer.resize(newSize, newSize, AnchorPosition.MIDDLECENTER);
    app.preferences.rulerUnits = startRulerUnits;  
})();

 

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

 

Originally from:

https://graphicdesign.stackexchange.com/questions/58812/specific-resize-layer-action

 

 

1 reply

Stephen Marsh
Community Expert
Community Expert
September 14, 2019

Try this action, it offers 2 different methods and you can turn off the dialog to use a fixed non-interactive size:

 

https://www.dropbox.com/s/h5d21n85aoh44p1/Resize%20Current%20Layer%20to%20Specific%20Pixel%20Size%20NOT%20Percentage.zip?dl=0

 

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

A scripted solution:

 

#target photoshop
(function (){
    var startRulerUnits = app.preferences.rulerUnits;  
    app.preferences.rulerUnits = Units.PIXELS;  
    var bounds = activeDocument.activeLayer.bounds;  
    var width = bounds[2].value - bounds[0].value;
    var newSize = (100 / width) * 300;  // 300px
    activeDocument.activeLayer.resize(newSize, newSize, AnchorPosition.MIDDLECENTER);
    app.preferences.rulerUnits = startRulerUnits;  
})();

 

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

 

Originally from:

https://graphicdesign.stackexchange.com/questions/58812/specific-resize-layer-action