How to Batch Resize in Photoshop
This doesn't seem to work, so I think a script way might be what I need.
The resize method in its JavaScript reference guide doesn't seem to cover this (p.64).
(parts of the image can be hidden)
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It only takes a minute to sign up.
Sign up to join this communityHow to Batch Resize in Photoshop
This doesn't seem to work, so I think a script way might be what I need.
The resize method in its JavaScript reference guide doesn't seem to cover this (p.64).
(parts of the image can be hidden)
Not entirely sure this is what you want....
If you want something to fill the canvas and maintain proportions, this script isn't for you.
I do this all the time. I struggled, like you, to find something that would not maintain proportions and merely fill the canvas, stretching or squishing as necessary.
I tried searching for where I may have originally found this script.. but honestly I have no clue. I may have even edited or corrected something else I found. It's been years since I first started using this script.
var doc = app.activeDocument;
var layer = doc.activeLayer;
layer.translate(new UnitValue(0-layer.bounds[0].as('px'),'px'), new UnitValue(0-layer.bounds[1].as('px'),'px'));
layer.resize((doc.width.value/(layer.bounds[2]-layer.bounds[0]))*100,(doc.height.value/(layer.bounds[3]-layer.bounds[1]))*100,AnchorPosition.TOPLEFT);
Will move a layer to top left corner of canvas, then resize to fill the canvas, not maintaining any proportion.
Note that nothing will be "hidden" using this script. When the script is called, all pixels on the highlighted layer in the Layer Panel will be forced to the canvas boundaries, regardless of what that does to the original proportions.
(If the original author presents themselves I'm happy to credit them.)
Here you go:
var doc = app.activeDocument;
var layer = doc.activeLayer;
var b = layer.bounds;
var layer_width = b[2] - b[0];
var layer_height = b[3] - b[1];
// put the layer in center
var layer_center_x = b[0] + layer_width/2;
var layer_center_y = b[1] + layer_height/2;
var doc_center_x = doc.width/2;
var doc_center_y = doc.height/2;
var shift_x = doc_center_x - layer_center_x;
var shift_y = doc_center_y - layer_center_y;
layer.translate(shift_x, shift_y);
// scale the layer
var scale_w = doc.width / layer_width;
var scale_h = doc.height / layer_height;
var scale = Math.max(scale_w, scale_h)*100;
layer.resize(scale, scale, AnchorPosition.MIDDLECENTER);