Something like this? The code below has been adjusted to default to 9 columns x 1 row.
Yes, it saves to PNG, however, it is easy enough to change the code to save to JPEG, but it would be good to know what JPEG settings. Perhaps show via screenshot what you would use in either save as copy or save for web legacy.
https://www.andrewnoske.com/wiki/Adobe_Photoshop_-_Scripts_Related_to_Montaging
// Takes the currently opened image, and allows the user to split it into
// a grid of PNG tiles, by specifying an number of columns and rows and a
// base file prefix.
//
// Tiles are created by duplicating the original image, cropping then saving.
// Tiles are saved in the form: 'C:/path/prefix0,0.png'
#target photoshop
if (documents.length != 1) {
alert("Must open exactly one image in photoshop first");
} else {
// Prompt user for number of columns and rows:
var cols = parseInt(prompt("How many columns?", 9));
var rows = parseInt(prompt("How many rows?", 1));
var total = cols*rows;
// Determine target tile size:
var image = app.documents[0];
var tileWidth = image.width / cols;
var tileHeight = image.height / rows;
// Draw guides along cuts:
for(col = 0; col <= cols; col++) {
image.guides.add(Direction.VERTICAL, col * tileWidth);
}
for(row = 0; row <= rows; row++) {
image.guides.add(Direction.HORIZONTAL, row * tileHeight);
}
// Prompt user to confirm, and for file prefix to save out to:
var savePath = File.saveDialog("Save Image File Prefix", "");
if(!savePath) {alert("Cancelled"); exit;}
if(!confirm("Create " + total + " tiles, each of " +
tileWidth + " x " + tileHeight + "?\n\n\n" +
"Tiles will be saved as '" + savePath.fsName +
"1,1.png' '...1,2.png' etc")) { exit; }
// For each tile:
for(row = 0; row < rows; row++) {
for(col = 0; col < cols; col++) {
// Determine crop coordinates (in pixels):
var top = row * tileHeight;
var bottom = top + tileHeight;
var left = col * tileWidth;
var right = left + tileWidth;
// Duplicate image, crop, save as PNG and close:
var tile = image.duplicate(); // Duplicate file.
cropCurrentDocument(top, left, bottom, right);
saveTileAsPng(tile, savePath.fsName, col, row);
tile.close(SaveOptions.DONOTSAVECHANGES);
}
}
}
function saveTileAsPng(img, origFilePath, col, row) {
var newFilePath = origFilePath + "_" + col + "," + row + ".png";
var newFile = new File(newFilePath);
var pngSaveOptions = new PNGSaveOptions();
activeDocument.saveAs(newFile, pngSaveOptions, true, Extension.LOWERCASE);
}
// Crops active document by a rectangle with the given pixel coordinages.
function cropCurrentDocument(top, left, bottom, right){
app.preferences.rulerUnits = Units.PIXELS;
activeDocument.selection.select(
[[left, top], [right, top], [right, bottom], [left, bottom]],
SelectionType.REPLACE, 0, false);
executeAction(charIDToTypeID( "Crop" ), new ActionDescriptor(),
DialogModes.NO );
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html