HDR v2.0 or improved HDR – part 3 – Windows and Linux script differences

How to make a script interactive ?

In the HDR script I made, most parameters – and especialy for Luminance – are pre set.
The only reason is because they work for me, and the output is most to my liking.
But sometimes I, and probably you to, want to change an operator,parameter or setting,
this is how to do that ( blue are script piecesred is a full script command ) :

Windows :
A Windows batch file needs no first line like in the Linux script (#!/bin/sh).
Start notepad, write down script, and save as .bat file.
Just double click to run it.
You can, if you want, start with a title:
TITLE Title of your script
use colors:
color 2E
Use Google to find more command line actions and options.
If you want the script to ask for input, use the set /p command
the set /p command tell’s the script what input to use in the designated input field.
set /p input=Enter the desired input :
rawtherapee %input%
If you would type –help, rawtherapee shows the help file.
If you would type the path to your pictures, rawtherapee starts the browser at that folder.
Use an apropriate set /p command and question for you to recognize what to do.

Lets take the luminance script line, and change a few parameters.
This is the original script line:
luminance-hdr-cli -t mantiuk06 -p contrast=0.90:equalization=false:saturation=1.5:detail=20 -g 0.75 neutral.tif negative-1.5.tif positive-1.5.tif -e 0,-1.5,+1.5 -o hdr-from-3.tif
Let us change contrast, saturation, detail and gamma :
set /p contrast=Input contrast parameter, choose value between 0.01 and 1.00
set /p saturation=Input saturation parameter, choose value between 0.01 and 2.0
set /p detail=Input detail parameter, choose value between 1.0 and 99,0
set /p gamma=Input gamma parameter, choose value between 0.01 and 3,00
In the script line, replace the value’s with %name-of-parameter%
luminance-hdr-cli -t mantiuk06 -p contrast=%contrast%:equalization=false:saturation=%saturation%:detail=%detail% -g %gamma% neutral.tif negative-1.5.tif positive-1.5.tif -e 0,-1.5,+1.5 -o hdr-from-3.tif

Windows syntax for RawTherapee batch file ( scriptname.bat )

set /p input=Enter Input parameter :
set /p output=Enter Output parameter :
set /p parameter=Enter extra parameter :
rawtherapee -w -o %output% -b8 -t -p profiles/bundeled-profile-name.pp3 %parameter% -Y -c %input%

Custom Profile in same folder as where terminal started :
rawtherapee -w -o %output% -b8 -t -p custom-profile-name.pp3 %parameter% -Y -c %input%

Custom profile in different folder :
set/p profilepath=Enter path to profile-no slash ad back :
rawtherapee -w -o %output% -b8 -t -p %profilepath%/custom-profile-name.pp3 %parameter% -Y -c %input%

Linux syntax for terminal script :
Open an editor like mousepad ( or any other notepad type editor )
Start script with : #!/bin/sh
Write down script – or copy paste a script
Save script :
The Linux common extention used for scripts is scriptname.sh,
but, also .bash is possible, and i think it will run on annything, even without extention.
But I always use the .sh extention, and mostly for recognition of what a script is and what not.
Then you need to make the script executable:
Run terminal in script folder ( right click – open terminal )
type : chmod +x scriptname.sh ( or whatever )
Run script by opening terminal in script folder
type ./scriptname

Almost the same as in Windows, you need to ask questions, and you need a variable.
In Linux you first ask the question:
echo “type input/output path, no end slash :”
then take the input with read followed by the variable
read output1
In the program command line, change %output% with $output
Like :
echo “type input/output path, no end slash :”
read output1
echo “type file extention format, example: *.DNG :”
read ext1
rawtherapee -o $output1/neutral.tif -b8 -t -c $output1/$ext1

Again let us take the luminance script line, and change a few parameters.
This is the original script line:
luminance-hdr-cli -t mantiuk06 -p contrast=0.90:equalization=false:saturation=1.5:detail=20 -g 0.75 neutral.tif negative-1.5.tif positive-1.5.tif -e 0,-1.5,+1.5 -o hdr-from-3.tif
Let us change contrast, saturation, detail and gamma :
echo “Input contrast parameter, choose value between 0.01 and 1.00:”
read contrast
echo “Input saturation parameter, choose value between 0.01 and 2.0:”
read saturation
echo “Input detail parameter, choose value between 1.0 and 99,0:”
read detail
echo “Input gamma parameter, choose value between 0.01 and 3,00:”
read gamma
In the script line, replace the value’s with $name-of-parameter
luminance-hdr-cli -t mantiuk06 -p contrast=$contrast:equalization=false:saturation=$saturation:detail=$detail -g $gamma neutral.tif negative-1.5.tif positive-1.5.tif -e 0,-1.5,+1.5 -o hdr-from-3.tif

Summary:

So, if you find scripts ( like mine ) with a simple setup – or have a syntax to be used with a certain program ( rawtherapee, luminancehdr, enfuse and many other, have a command line syntax that is Windows/Linux and even Mac independent )
you can easily make interactive and adapt from Windows to Linux or from Linux to Windows if you have the following command line conversion :
Windows :
ask question and set variable : set /p input=enter input parameter
set variable in program line : %input%
Linux :
ask question : echo “enter input parameter”
set variable : read input
set variable in program line : $input

Using a Menu in a script :

When using a menu you can do almost anything you want in one single script, combine different programs, and even automate complete workflows.
Below I have a very simple setup for a script with menu – examples for both Windows and Linux.

Linux Menu Script with three options :

#!/bin/bash

echo ” script menu”
echo ” ———–“
echo “Choose one of the following options:”
echo
echo “[1]- first option”
echo “[2]- second option”
echo “[3]- third option”

read runoption

case “$runoption” in

“1”)
# first option – here an example with luminance.
echo “Input contrast parameter, choose value between 0.01 and 1.00:”
read contrast
echo “Input saturation parameter, choose value between 0.01 and 2.0:”
read saturation
echo “Input detail parameter, choose value between 1.0 and 99,0:”
read detail
echo “Input gamma parameter, choose value between 0.01 and 3,00:”
read gamma
luminance-hdr-cli -t mantiuk06 -p contrast=$contrast:equalization=false:saturation=$saturation:detail=$detail -g $gamma neutral.tif negative-1.5.tif positive-1.5.tif -e 0,-1.5,+1.5 -o hdr-from-3.tif
;;

# second option.
“2”)
here you write the command line’s
;;

# third option.
“3”)
here you write the command line’s
;;

esac

exit

Windows Menu Script with options ( copy of my old RawBat.bat script – fully operational )
This script features a double menu, is easy to adapt to single menu and any workflow situation featuring multiple programs and command lines.
To get the menu view correct, you need to edit the script code in a good editor like notepad++:setup_menu

TITLE RawBat v1.0 – RawTherapee Batch Converter – Setup
color 2E
@echo off
CLS
CLS
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍṠ
ECHO ẃ ẃ
ECHO ẃ RawTherapee Batch Converter – Setup ẃ
ECHO ẃ ————————————— ẃ
ECHO ẃ ẃ
ECHO ẃ 1. Select input, then output folder ẃ
ECHO ẃ ẃ
ECHO ẃ Ex. C:\Pictures\IN\ ẃ
ECHO ẃ Ex. C:\Pictures\OUT\ ẃ
ECHO ẃ ẃ
ECHO ẃ 2. Go To Batch Menu ẃ
ECHO ẃ ẃ
ECHO ẃ ẃ
ECHO ẃ ẃ
ECHO ẃ Q. Quit ẃ
ECHO ẃ ẃ
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍỳ

set /p Choice=Enter: 1,2,3,.. or Q to Quit –
echo.

if [%Choice%]==[1] goto input_output
if [%Choice%]==[2] goto batch_menu
if [%Choice%]==[q] goto end
if [%Choice%]==[Q] goto end
For %%a in (1,2,3,..9,q,Q) do if not [%Choice%]==[%%a] goto end

@echo off
CLS
echo.

:input_output
echo.
set /p input=Enter Input parameter :
echo.
echo.
set /p output=Enter Output parameter :
echo.
goto setup_menu

:batch_menu
TITLE RawBat v1.0 – RawTherapee Batch Converter – Menu
color 2E
@echo off
CLS
CLS
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍṠ
ECHO ẃ ẃ
ECHO ẃ RawTherapee Batch Converter ẃ
ECHO ẃ ————————————— ẃ
ECHO ẃ ẃ
ECHO ẃ 1. JPG Provia – output 70 percent ẃ
ECHO ẃ ẃ
ECHO ẃ 2. TIFF 8 bit Astia (Soft) ẃ
ECHO ẃ ẃ
ECHO ẃ 3. TIFF 8 bit Provia (Standard) ẃ
ECHO ẃ ẃ
ECHO ẃ 4. TIFF 8 bit Velvia (Vivid) ẃ
ECHO ẃ ẃ
ECHO ẃ 5. TIFF 8 bit Fortia (Extreme Vivid) ẃ
ECHO ẃ ẃ
ECHO ẃ 6. TIFF Neutral (RAW Tiff) ẃ
ECHO ẃ ẃ
ECHO ẃ 7. Black and White ẃ
ECHO ẃ ẃ
ECHO ẃ 8. Run RawTherapee in folder ẃ
ECHO ẃ ẃ
ECHO ẃ 9. input extra parameter ẃ
ECHO ẃ ẃ
ECHO ẃ Q. Quit ẃ
ECHO ẃ ẃ
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍỳ

set /p Choice=Enter: 1,2,3,.. or Q to Quit –

echo.

if [%Choice%]==[1] goto jpg_Provia70
if [%Choice%]==[2] goto tiff_Astia
if [%Choice%]==[3] goto tiff_Provia
if [%Choice%]==[4] goto tiff_Velvia
if [%Choice%]==[5] goto tiff_Fortia
if [%Choice%]==[6] goto tiff_Neutral
if [%Choice%]==[7] goto tiff_BW
if [%Choice%]==[8] goto Rawtherapee_Gui
if [%Choice%]==[9] goto parameter
if [%Choice%]==[q] goto end
if [%Choice%]==[Q] goto end
For %%a in (1,2,3,..9,q,Q) do if not [%Choice%]==[%%a] goto end
:jpg_Provia70
color 1F
echo Develop JPG Provia 70%
echo.
rawtherapee -w -o %output% -j70 -js3 -p profiles/Provia.pp3 %parameter% -Y -c %input%
goto batch_menu

:tiff_Astia
color 1F
echo Develop TIFF Astia
echo.
rawtherapee -w -o %output% -b8 -t -p profiles/Astia.pp3 %parameter% -Y -c %input%
goto batch_menu

:tiff_Provia
color 1F
echo Develop TIFF Provia
echo.
rawtherapee -w -o %output% -b8 -t -p profiles/Provia.pp3 %parameter% -Y -c %input%
goto batch_menu

:tiff_Velvia
color 1F
echo Develop TIFF Velvia
echo.
rawtherapee -w -o %output% -b8 -t -p profiles/Velvia.pp3 %parameter% -Y -c %input%
goto batch_menu

:tiff_Fortia
color 1F
echo Develop TIFF Fortia
echo.
rawtherapee -w -o %output% -b8 -t -p profiles/Fortia.pp3 %parameter% -Y -c %input%
goto batch_menu

:tiff_Neutral
color 1F
echo Develop TIFF Neutral
echo.
rawtherapee -w -o %output% -b8 -t %parameter% -Y -c %input%
goto batch_menu

:tiff_BW
color 1F
echo Develop TIFF Black and White
echo.
rawtherapee -w -o %output% -b8 -t -p profiles/BW.pp3 %parameter% -Y -c %input%
goto batch_menu

:Rawtherapee_Gui
color 1F
echo Open Rawtherapee in selected folder
echo.
rawtherapee %input%
goto batch_menu

:parameter
set /p parameter=Enter extra parameter :
echo.
goto batch_menu

:end
exit

Have fun !

2 Comments

  1. On linux you might want to try Zenity which is a very simple but powerful GTK dialog framework designed for script. Typing paths are definitely more complicated than to select them graphically. Zenity also allows you to define default value.

    Here is an intro:
    http://www.howtogeek.com/107537/how-to-make-simple-graphical-shell-scripts-with-zenity-on-linux/

    And the manual:
    http://manpages.ubuntu.com/manpages/precise/en/man1/zenity.1.html

Leave a Reply

Your email address will not be published. Required fields are marked *