User Tools

Site Tools


Render Post-Process

Summary

Daz Studio 4.8.0.21 added support for a script that could be executed immediately following a render being saved to file. This post-render-save script can be set/retrieved via the General > Post-Processing > Post Process Script property, found on the Editor page of the Render Settings pane.

When executed, an array consisting of the absolute path to the file(s) written to disk is passed to the script.

Below is an example demonstrating how to perform an operation on a rendered image once it has been saved to file, via script. While this example is very basic, only causing the image(s) to be opened, this mechanism can be used for a multitude of post-processing operations.

API Areas of Interest

Example

Render_Post_Process.dsa
// DAZ Studio version 4.8.0.21 filetype DAZ Script
 
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function( aArgs ){
 
	// Declare working variables
	var vArg;
	var sType, sAbsolutePath;
 
	// If the application version is 4.9.3.29 or newer
	var bUseNewAPI = (App.version64 >= 0x000400090003001d);
 
	// Create a new file info object
	var oFileInfo = new DzFileInfo( "" );	
 
	// Iterate over the arguments passed to the script
	for( var i = 0, nArgs = aArgs.length; i < nArgs; i += 1 ){
		// Get the 'current' argument
		vArg = aArgs[ i ];
 
		// Get the 'current' type
		sType = typeof( vArg );
 
		// If the argument isn't a string
		if( sType != "object" ){
			// Next!!
			continue;
		}
 
		// If we're using the new API
		if( bUseNewAPI ){
			oFileInfo.setFile( vArg );
		// Otherwise
		} else {
			// Clean up; don't leak memory
			oFileInfo.deleteLater();
			// Create a new file info object
			oFileInfo = new DzFileInfo( vArg );
		}
 
		// If the file exists on disk
		if( oFileInfo.exists() ){
			// If we're using the new API
			if( bUseNewAPI ){
				// Get the absolute path of the file
				sAbsolutePath = oFileInfo.absoluteFilePath();
			// Otherwise
			} else {
				// Get the absolute path of the file
				sAbsolutePath = oFileInfo.absFileName();
			}
 
			// Prompt the operating system to perform its default handling of the given file type
			App.showURL( String("file:///%1").arg( sAbsolutePath ) );
		}
	}
 
	// Clean up; don't leak memory
	oFileInfo.deleteLater();
 
// Finalize the function and invoke
})( getArguments() );