PhotoMesh supports the integration of external tools and scripts, allowing on-the-fly processing of each photo loaded into the project. This includes reading or writing file formats that PhotoMesh does not support directly, extracting data from photos, or even deleting each photo after it has been processed. These tasks are distributed across multiple machines using PhotoMesh's fuser mechanism.
PhotoMesh supports two types of hooks:
-
Loader Hook: Uses external software to convert photos in unsupported formats to JPG or TIF before they are processed by PhotoMesh.
-
Post Hook: Allows tasks to be performed on the original or processed photos, including those handled by the Loader Hook. This includes converting photos processed by PhotoMesh into another format for use in other applications.
Both hooks are configured using a JSON file placed in the fuser directory under a manually created hook folder. This JSON file references a batch file that runs the external software or script. See the attached sample hook files for reference.
In PhotoMesh build settings, these hooks are activated using AT flags, which reference only the JSON file names (without the .json extension). More about Setting AT flags in PhotoMesh build settings >
E.g., for convertRaw.json, use:
@featuredetect2[loaderhook=convertRaw]
For convertJP2.json, use:
@featuredetect2[posthook=convertJP2]
General Workflow for Using Hooks in PhotoMesh
- Navigate to your PhotoMesh installation folder, usually located at: C:\Program Files\Skyline\PhotoMesh.
- Inside the Fuser folder, create a new folder named hook.
- Place your hook JSON file inside the newly created hook folder.
- Start a new project in PhotoMesh.
- Load photos into the project. You can also load unsupported file formats, e.g., by importing a CSV or XML file that specifies each photo’s location and parameters.
- Start the build process and add the relevant hook flag in the AT section.
Loader Hook
The loader hook is used specifically to prepare photos for use in PhotoMesh, typically by converting them from unsupported formats (e.g., RAW) into formats PhotoMesh can process (e.g., JPG or TIF). If you're not preparing photos before PhotoMesh processes them, use a post hook instead.
The loader hook runs a batch file and supports the following placeholders:
- {in_path} – Path to the input file that needs to be processed.
- {out_path} – Path where the converted file should be saved (used by PhotoMesh).
- {smpt_path} – Path to PhotoMesh’s internal SMPT file (optional).
When the batch file is executed, PhotoMesh replaces these placeholders with actual paths and passes them as command-line arguments (%1, %2, %3 in the .bat file). If you don’t specify an output extension, PhotoMesh assumes .jpg.
Example: Configuring a loader hook that converts RAW photos to JPG using RawTherapee.
1. Create the JSON file
Create a file named convertRaw.json with the following content:
{
"cmd": "'\\\\<MyComputer>\\C\\Tools\\convertRaw.bat' \"{in_path}\" \"{out_path}\" \"{smpt_path}\"",
"ext": "jpg"
}
-
Replace <MyComputer> with the name of a computer or server that has a shared folder accessible over the network.
- cmd: Command to run the batch file for conversion.
- ext: Output format from RawTherapee, e.g., "jpg" or "tif".
- {in_path}, {out_path}, {smpt_path} placeholders:
Placeholder Passed as Description {in_path} %1 Full path to the RAW input file {out_path} %2 Full path where the converted file will be saved {smpt_path} %3 Full path to PhotoMesh's internal SMPT file
2. Create the Batch file
Save the following as convertRaw.bat:
"\\<MyComputer>\C\Program Files\RawTherapee\rawtherapee-cli.exe" -c %1 -p "Processing Profile.pp3" -j100 -o %2
This command:
- Reads the RAW file from %1
- Uses RawTherapee to convert the file
- Saves the resulting JPG to %2
Post Hook
The post hook runs after PhotoMesh processes the photos and can operate on the following placeholders:
- {in_path} – Original input photo
- {tmp_path} – Temporary TIF generated by PhotoMesh
- {smpt_path} – Path to the SMPT file
When the batch file is executed, PhotoMesh replaces these placeholders with actual paths and passes them as command-line arguments (%1, %2, %3 in the .bat file). Their order in the JSON determines their argument position in the batch file: %1, %2, %3.
Example: Configuring a post hook that converts TIF or JPG files to JP2 format using ImageMagick for use in other applications.
1. Create the JSON file
Create a JSON file named convertJP2.json with the following content:
{
"cmd": "'\\\\<MyComputer>\\Tools\\convertJP2.bat' \"{in_path}\" \"{tmp_path}\" \"{smpt_path}\""
}
- cmd: Command to run the batch file to convert input to JP2 format.
- {in_path}, {tmp_path}, {smpt_path} placeholders:
Placeholder Passed as Description {in_path} %1 Full path to the original input photo {tmp_path} %2 Full path to the temporary TIF file PhotoMesh generates for compatibility with external tools (especially useful if the original file is in an uncommon format like IIQ). The TIF files include any processing done during the Photo Preparation, for example, photos after brightness histogram correction if using the Local brightness histogram correction for images (CLAHE) preset. {smpt_path} %3 Full path to PhotoMesh's internal SMPT file
2. Create the Batch file
Save the following as convertJP2.bat:
"\\<MyComputer>\C\Program Files\ImageMagick\magick.exe" %2 -quality 0 -define jp2:progression-order=RPCL "\\<MyComputer>\<PmProject>\jp2\%~n3.jp2"
This command:
- Reads the processed TIF file from %2
- Converts it to JP2 format using ImageMagick
- Saves it to the jp2 folder, using the base name of the SMPT file as the filename (%~n3 extracts just the filename without extension from that argument).
Alternatively, you can use the original input file instead of the TIF:
"\\<MyComputer>\C\Program Files\ImageMagick\magick.exe" %1 -quality 0 -define jp2:progression-order=RPCL "\\<MyComputer>\<PmProject>\jp2\%~n3.jp2"
Note: The JP2 output directory must be created manually. It does not necessarily need to be within the PhotoMesh project directory.