Created
June 13, 2017 22:41
-
-
Save stevechap416/d5f1ba3e79b0d6b235c5bfcb15915695 to your computer and use it in GitHub Desktop.
Prepare a Rendered VR Cubemap for Post Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Exports out the 12 images that make up cube maps into the current folder. | |
//Make sure you have your export setting setup correctly in PS so no hyphens are added to your filename. | |
//Check here: http://thesetchells.com/2012/06/preventing-dashes-hyphens-photoshop-save-web/ | |
//Works on flattened images. | |
var doc = app.activeDocument; | |
var docName = doc.name.substr(0,doc.name.length-4); | |
var exportName = docName + "_split"; | |
var dir = doc.path.toString()+"/"; | |
var options = new ExportOptionsSaveForWeb(); | |
options.format = SaveDocumentType.JPEG; | |
options.quality = 100; | |
// Set rulerUnits to pixels | |
app.preferences.rulerUnits = Units.PIXELS; | |
//Unlock layers | |
docLay=app.activeDocument.layers; | |
l=app.activeDocument.layers.length; | |
while (l>0) { | |
l--; | |
docLay[l].isBackgroundLayer = false; | |
docLay[l].allLocked = false; | |
} | |
//Get Document dimensions | |
var w = app.activeDocument.width; | |
var h = app.activeDocument.height; | |
var CanvasCutHeight = h; | |
var CanvasCutWidth = (w/12); | |
//Shrink the canvas | |
doc.resizeCanvas(CanvasCutWidth, CanvasCutHeight, AnchorPosition.TOPLEFT); | |
var layerToSplit = doc.artLayers.getByName("Background"); | |
//Now export out each square and offset to the next one. | |
for (var i = 0; i <12; i++) { | |
doc.exportDocument (new File(dir + "/" + exportName + (i+1) + ".jpg"), ExportType.SAVEFORWEB, options); | |
layerToSplit.applyOffset((-CanvasCutWidth), 0, OffsetUndefinedAreas.WRAPAROUND); | |
} | |
//Reset their file back to it's original state. | |
history = doc.historyStates.length - 15; | |
doc.activeHistoryState = doc.historyStates[history]; | |
//app.purge (PurgeTarget.HISTORYCACHES); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment