PhotoGrok Scripting

painter
Histogram and Highlights Script (See Example Section Below)

Nutshell Overview
Advanced users can create custom JavaScript programs that run in PhotoGrok. These scripts can control how the tree is filtered, collect data about the images and even draw on the main image screen. Scripts are useful when used in conjunction with JavaScript filters. The scripting window is opened by pressing Ctrl+Shift+J. There is a small API to communicate with PhotoGrok. Scripts are saved with settings. The following functions can be called:


New functions in PhotoGrok 2.41:


New functions in PhotoGrok 2.42:


New functions in PhotoGrok 2.43:


New functions in PhotoGrok 2.55:


New functions in PhotoGrok 2.56:


Modified functions in PhotoGrok 2.57:


Modified functions in PhotoGrok 2.58:


Modified functions in PhotoGrok 2.59:


JavaScript filters (including those defined in custom tags) run in the same scope and therefore can access variables and functions from the main script - a filter is called against every image as the tree is created. Global variables are cleared between each execution. Use getMap() to persist data if necessary. The main script is evaluated when the script window is closed, when a new setting is loaded and when a tree or catalog is built manually (not through automated script functions).

Scripts can call the full Java API (see Java's Rhino and/or Nashorn documentation).

Painter
Starting with version 2.41, advanced users can write JavaScript functions that can paint on the main image screen. This can be used to implement histograms (see example) to things like face recognition and image filters. In version 2.42, the "Apply Painter" checkbox in preferences allows a painted image to be exported. A painter is defined and registered as follows:

setPainter(function(gfx, scaledImage, fullImage, painterProps){
	// draw the file name on the image
	gfx.setColor(Color.RED);
	gfx.drawString(painterProps.file, 20, 50);
});

Function Parameters:


painterProps Properties: