Tiled Landscape

After several failed attempts at other methods, I found Photoshop’s scripting reference.


var absoluteSavePath = "D:\\Users\\aszecsei\\Documents\\Tiled\\"

doc = app.activeDocument; 

var tiles = prompt("How many tiles do you want?", 4, "Tile Amount");
var tileSize = ((doc.height-1)/tiles)+1;
var tileOffset = tileSize-1;
for(var x=0; x<tiles; x++)
{
    for(var y=0; y<tiles; y++)
    {
        app.documents[0].duplicate();
        var bounds = [x*tileOffset, y*tileOffset, x*tileOffset + tileSize, y*tileOffset+tileSize];
        active = app.activeDocument;
        active.crop(bounds);
        saveOptions = new RawSaveOptions();
        active.saveAs(new File(absoluteSavePath + "tile_x" + x + "_y" + y + ".raw"), saveOptions, true);
        active.close(SaveOptions.DONOTSAVECHANGES);
    }
}

Imported everything in, and it all turned out nicely.

I’ll make a few edits to the code (make the “tile” name user-defined on run, figure out how to get relative save paths working, add a menu option) and release the plugin for anyone to use.