Different kind of Fit Image?

BL
Posted By
Brian_Lake
Jan 30, 2009
Views
350
Replies
6
Status
Closed
Is it possible to get the fit image (or even a combination of image size tools) to fit the smallest dimension to a specific size?

Reason being is I’d like my action to fit the smallest dimension and than simply crop off the opposite dimension to end up with a square as the final image.

How to Improve Photoshop Performance

Learn how to optimize Photoshop for maximum speed, troubleshoot common issues, and keep your projects organized so that you can work faster than ever before!

P
Phosphor
Jan 30, 2009
I think it could be done with an Action, but which part (side) of the image would you want cropped and which to keep?
P
Phosphor
Jan 30, 2009
I’m thinking along the lines of:

Make Background a Layer. Increase Canvas Size to 200% both dimensions. Select Transparency Channel (double-click on the Layer thumbnail). Transform Selection>Rotate 90 degrees. Align to Left and Top (say) and Crop. Then Select Transparency Channel again, Crop.

That would give you a square of the Top for Portrait images and the Left for Landscape images I think.
BL
Brian_Lake
Jan 30, 2009
Yea maybe I’ll just have to have two separate actions for portrait or landscape. I just wondered if there was a trick I didn’t know about.

Thanks for the responses!
P
Phosphor
Jan 30, 2009
I think you only need one. See my instructions, above. The only issue is which portion of the image you want to keep.
CP
christoph_pfaffenbichler
Jan 30, 2009
Brian, You could copy this into a jsx-file, put it into Presets – Scripts and give it a try:

// crop to a square of the document’s shorter side’s length;

// use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var originalRulerUnits = preferences.rulerUnits;

preferences.rulerUnits = Units.PIXELS;

var theShorter = getTheShorter(Number(myDocument.width), Number(myDocument.height));

var dlg = new Window ("dialog", "select new length for shorter side in pixels", [300,300,600,380]);

dlg.theNewLengthField = dlg.add(‘edittext’, [12,12,285,35], theShorter, {multiline:false});

dlg.theNewLengthField.active = true;

dlg.buildBtn = dlg.add(‘button’, [12,45,140,55], ‘OK’, {name:’ok’});

dlg.cancelBtn = dlg.add(‘button’, [160,45,285,45], ‘Cancel’, {name:’cancel’});

var myReturn = dlg.show ();

if (myReturn == true) {

var theNewLength = Number(dlg.theNewLengthField.text);

if (myDocument.width >= myDocument.height) {

myDocument.resizeImage (null, theNewLength, null, ResampleMethod.BICUBIC);

// the anchor-positions are easily changed to TOPLEFT, BOTTOMRIGHT etc.;

myDocument.resizeCanvas (theNewLength, theNewLength, AnchorPosition.MIDDLECENTER)

}

else {

myDocument.resizeImage (theNewLength, null, null, ResampleMethod.BICUBIC);

myDocument.resizeCanvas (theNewLength, theNewLength, AnchorPosition.MIDDLECENTER)

}

};

preferences.rulerUnits = originalRulerUnits;

}

else {

alert ("no document open")

};

function getTheShorter(a,b) {

if (a <= b) {

var x = a}

else {

var x = b};

return x;

};
BL
Brian_Lake
Jan 30, 2009
oh wow thank you for writing that up for me! I’ll have to give it a try

How to Master Sharpening in Photoshop

Give your photos a professional finish with sharpening in Photoshop. Learn to enhance details, create contrast, and prepare your images for print, web, and social media.

Related Discussion Topics

Nice and short text about related topics in discussion sections