Answered
I know that it is possible to set a specific pixel size and resolution when using the crop tool. The crop border will then be constrained to the aspect ratio of your chosen dimensions as you drag and move etc. Then when you commit the crop it will resize the image to the specific pixel dimensions you have given.
But, that is not what I want to do. Importantly, setting the dimensions does nothing to the crop border. If I have a 1000x1000 px image and specify a 100x100 px crop, the border remains at 1000x1000 px and I have to drag the handles to 100x100 px if I want to crop to a specific 100x100 px region. This is an absurd pain the backside when working with a trackpad, trying to hit the exact size takes way too long.
I want to be able to set a specific size in pixels and for the crop border to assume that size. Then I can drag the crop around and get those exact pixel dimensions from the region I want.
I was a long time user of PaintShop Pro prior to Photoshop. In PSP you could just enter the pixel dimensions and the crop border snapped to that exact size.
Am I missing something simple here?
Thanks in advance.
The following script will create a rectangular selection at the width and height entered into the prompts. By default, it is drawn at the upper left (0x 0y).
You can then position the marquee where you wish to crop, then use Image > Crop.
At least you will get your desired size, I hope that this helps!
// Create Rectangular Selection from Prompts.jsx
#target photoshop
(function () {
/* Width Input */
// Loop the input prompt until a number is entered
var origWidth;
while (isNaN(origWidth = prompt("Selection width in pixels:", "100")));
// Test if cancel returns null, then terminate the script
if (origWidth === null) {
alert('Script cancelled!');
return
}
// Test if an empty string is returned, then terminate the script
if (origWidth === "") {
alert('A value was not entered, script cancelled!');
return
}
// Convert decimal input to integer
var widthToInteger = parseInt(origWidth);
/* Height Input */
// Loop the input prompt until a number is entered
var origHeight;
while (isNaN(origHeight = prompt("Selection height in pixels:", "100")));
// Test if cancel returns null, then terminate the script
if (origHeight === null) {
alert('Script cancelled!');
return
}
// Test if an empty string is returned, then terminate the script
if (origHeight === "") {
alert('A value was not entered, script cancelled!');
return
}
// Convert decimal input to integer
var heightToInteger = parseInt(origHeight);
/* Call the Rectangular Selection Function */
setRectSel(0, 0, heightToInteger, widthToInteger);
/* Set Rectangular Selection Function */
function setRectSel(top, left, bottom, right) {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty(s2t("channel"), s2t("selection"));
descriptor.putReference(c2t("null"), reference);
descriptor2.putUnitDouble(s2t("top"), s2t("pixelsUnit"), top);
descriptor2.putUnitDouble(s2t("left"), s2t("pixelsUnit"), left);
descriptor2.putUnitDouble(s2t("bottom"), s2t("pixelsUnit"), bottom);
descriptor2.putUnitDouble(s2t("right"), s2t("pixelsUnit"), right);
descriptor.putObject(s2t("to"), s2t("rectangle"), descriptor2);
executeAction(s2t("set"), descriptor, DialogModes.NO);
}
/* Select the Rectangular Marquee Selection tool */
(r = new ActionReference()).putClass(stringIDToTypeID('marqueeRectTool'));
(d = new ActionDescriptor()).putReference(stringIDToTypeID('target'), r);
executeAction(stringIDToTypeID('select'), d, DialogModes.NO)
})
();
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html
Sign up
Already have an account? Login
To post, reply, or follow discussions, please sign in with your Adobe ID.
Sign inSign in to Adobe Community
To post, reply, or follow discussions, please sign in with your Adobe ID.
Sign inEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.
