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