
@echo off
REM Original batch file created 7 March 2014 by Emulator
REM This 480 patch batch file created 26 April 2014 on the lines
REM demonstrated by pharmacist.

REM This batch file brings together all the necessary Argyll commands in the
REM appropriate order for the creation of a printer profile.
REM The sequence of commands used by Argyll CMS is: targen - printtarg - chartread - colprof
REM The command options included produce a working profile from a patch
REM target on A4 paper. These options may be changed by the 
REM user through editing the batch file. Verbose mode gives step by step screen 
REM information as processing progresses.

:startpoint
echo.
echo.
echo.
echo.
echo.
echo                                   CAP480.BAT
echo.
echo            Create Argyll 480 patch profiles on a single A4 sheet
echo.
echo              Which Argyll profiling operation do you require?
echo.
echo.
echo     targen      - Generate target chart patch values           - 1
echo     printtarg   - Create patch .tif file for printing target   - 2
echo     chartread   - Read printed chart patch values              - 3
echo     colprof     - Create profile                               - 4
echo     mmmunki     - Read printed chart patch values 5 times      - 6
echo     To exit  program                                           - 5
echo.
set chr=""
set /p chr=             Enter (1,2,3,4,6 or 5):
echo.
echo.
echo.

if %chr%=="" goto :startpoint
if %chr%==1 goto :lab1
if %chr%==2 goto :lab2
if %chr%==3 goto :lab3   
if %chr%==4 goto :lab4
if %chr%==6 goto :lab3b 
if %chr%==5 goto :end
goto :startpoint

REM generate target values .ti1 file (targen)
REM -v gives verbose mode, -d2 gives print RGB, -G gives optimized rather than fast points,
REM -e6 gives 6 white and -B5 gives 5 black patches, -g128 gives 128 patches on grey axis,
REM -f480 gives 480 patches in total.

:lab1
set pcn1=targen480
set pcn1=%date:/=-%-%pcn1%
targen -v -d2 -G -e6 -B5 -g128 -f480 %pcn1%
echo %pcn1%.ti1 file complete
pause
goto :startpoint

REM create .tif file ready for printing targets and .ti2 file (printtarg)
REM -v gives verbose mode, -ii1 use I1Pro, iCM use ColorMunki (however using CM in I1Pro 
REM mode reads smaller patches), -a1.05 is a patch and spacer scaling factor, -A0.6 is an
REM additional spacer scaling factor, -T300 gives 16 bit TIFF raster file with 300 DPI,
REM -R21 gives chart random start number 21, -m2 (M2 for TIFF) gives page margin in mm,
REM -P means don't limit strip length, -p210x297 gives A4 page width by height 
REM in mm.

:lab2
set pcn2=targen480
set pcn2=%date:/=-%-%pcn2%
REM printtarg -v -ii1 -a1.05 -A0.6 -T300 -R21 -m2 -P -pA4 %pcn2%
printtarg -v -ii1 -a1.15 -A0.6 -T300 -R21 -m0 -P -L -pA4 %pcn2%
REM printtarg -v -ii1 -a1.13 -A0.6 -L -T300 -R21 -m2 -P -pA4R %pcn2%
REM printtarg -v -iCM -a0.6 -m0 -L -T300 -R21 -n -P -p370x250 %pcn2%
REM printtarg -v -iCM -a0.6 -m0 -L -T300 -R21 -n -P -p380x240 %pcn2%
REM printtarg -v -iCM -h -m0 -L -T300 -R21 -n -P -p212x300 %pcn2%
echo %pcn2%.ti2 and %pcn2%.tif  files complete
pause
goto :startpoint

REM read chart values to .ti3 file (chartread)
REM -v gives verbose mode, -H gives high resolution spectrum mode, -T0.4 modifies strip patch
REM consistency tolerance ratio, pcn2 (targen480) becomes the .ti3 file name.



:lab3
if "%pcn2%" == "" goto :maninput
chartread  -v -H -T0.4 %pcn2%
goto :startpoint

:maninput 
set/p pcn2= Enter the name of the .ti2 file (omit the .ti2):
goto:lab3


REM read chart values to .ti3 file (chartread)
REM -v gives verbose mode, -H gives high resolution spectrum mode, -T0.4 modifies strip patch
REM consistency tolerance ratio, pcn2 (targen480) becomes the .ti3 file name.



:lab3b
if "%pcn2%" == "" goto :maninput2
mmmunki -TI3 -PM5 -A3 %pcn2%.ti2 %pcn2% 
goto :startpoint

:maninput2 
set/p pcn2= Enter the name of the .ti2 file (omit the .ti2):
goto:lab3b


REM create the .icm profile (colprof)
REM This version of "createprofile.bat" uses the same name for both the internal ICC Description
REM tag file name and the external name for your printer profile. Application software vary in the 
REM use of these names, which can be confusing.
REM It adds the date to the front end of the file name and automatically adds " " quotation marks
REM around the file names.
REM It also enters "Argyll - copyright free use" in the copyright description.

REM -v gives verbose mode and the max and avg fit errors at the end of colprof,
REM -qh gives quality high, -i D50 gives D50 illuminant, -o gives observer 1931_2,
REM -S AdobeRGB 1998.icc applies Adobe to output profile for perceptual and
REM saturation B2A tags, -cmt sets input viewing conditions for gamut mapping to monitor in
REM typical environment, -dpp sets reflection print as output viewing conditions, -D%par1% sets
REM the profile internal description tag, -C%par2% sets the copyright tag, %par3% sets the file 
REM name for the .ti3 file consider -r 1.0 for more smooth

:lab4
set /p par1= Enter the NAME for the profile file:
if "%par1%" == "" goto :startpoint
set par1="%date:/=-% %par1%"
set par2="Argyll - copyright free use"
set /p par3= Enter the NAME of the .ti3 file created by the chartread command (omit the .ti3): 
if "%par3%" == "" goto :startpoint
set par3= "%par3%"
set par4= %par1%
colprof -v -qh -i D50 -o 1931_2 -S AdobeRGB1998.icc -cmt -dpp -D%par1% -C%par2% %par3%
rename  %par3%.icm %par4%.icm
pause

:end pause
exit