New with ON1 PHOTO RAW 2022 you can now "Run a Script After Export"
In the new Export dialog, there is an After Export option to run a script. This is a powerful tool that advanced users can use to extend and automate their workflow.
Note: This is an advanced feature for users with knowledge of scripting. ON1 technical support cannot provide support in creating or debugging your scripts.
By enabling the option, the script text edit field is enabled. Put the full path of any executable in this field.
Examples:
Windows:
c:\myscripts\myexport.bat
MacOS:
/bin/sh ~/Documents/myexport.sh
Use the executable location for any scripting language.
Any output from the program or script will be saved to the ON1 PhotoRaw log file.
The batch file:
echo "This is a .bat"
will log this to the application log file:
ON1 - Export Script:
C:\Suite\PerfectLayers\Projects\Win>echo "This is a .bat"
"This is a .bat"
The script is run once for each file that is exported. Export will wait for the script to finish before proceeding to the next file.
Script Arguments
The script line item can accept arguments. The arguments can be static, or use a set of variables provided by ON1 PhotoRaw.
C:\Users\josh\AppData\Local\Programs\Python\Python37\python.exe C:\myscripts\test1.py 42
This basic python program looks like this:
# Contents of C:\myscripts\test1.py
import sys
value1 = sys.argv[1]
print("Hello PhotoRaw %s" % value1)
Produces the output:
ON1 - Export Script: Hello PhotoRaw 42
Here is a more complicated example using variables provided by PhotoRaw:
C:\Users\josh\AppData\Local\Programs\Python\Python37\python.exe C:\myscripts\test2.py %filepath% %rating%
Example test2.py
import sys
filepath = sys.argv[1]
rating = sys.argv[2]
print("Path: %s" % filepath)
print("Rating: %s" % rating)
Produces the output:
ON1 - Export Script: Path: C:\Users\josh\Desktop\export\_DSC9736 3.jpg
Rating: 4
The provided variables are:
%filename% |
The filename of the exported photo. |
%filepath% |
The path of the exported photo. |
%guid% |
ON1 PhotoRaw’s internal ID of this photo. |
%size% |
The exported file size of the photo. |
%rating% |
The metadata rating of the photo. |
%userflag% |
The Like/Dislike flag of the photo. |
%preset% |
Name of export preset. This will be none for just the current settings. |
A more complex example:
Export script entry:
C:\Users\josh\AppData\Local\Programs\Python\Python37\python.exe c:\bin\log.py %filename% %filepath% %guid% %rating%
'''
This script logs the first parameter to log.txt, then creates a thumbnail with the rating draw in text over the thumbnail.
'''
import sys
filename = sys.argv[1]
filepath = sys.argv[2]
guid = sys.argv[3]
rating = sys.argv[4]
fio = open("c:\\bin\\log.txt", "a+")
fio.write("\n********************\n")
fio.write(filename)
fio.write("\n")
fio.write(filepath)
fio.write("\n")
fio.write(guid)
fio.write("\n")
try:
from PIL import Image, ImageDraw
path = filepath[:filepath.rfind("\\")+1]
im = Image.open(filepath)
im.thumbnail((160, 120))
draw = ImageDraw.Draw(im)
draw.text((10,10), "Rating: %s" % rating, fill=(255,0,0,128))
draw.text((10,40), filename, fill=(0,0,0,128))
outfile = "%s%s_thumb_%s.JPG" % (path, guid, rating)
im.save(outfile, "JPEG")
fio.write(outfile)
fio.write("\n")
except Exception as e:
fio.write(str(e))
fio.write("\n")
fio.close()
Comments
0 comments
Article is closed for comments.