72badd81cb166498e5c7ce22f3f0b681447e8df5
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / create_aces_config.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Defines objects creating the *ACES* configuration.
6 """
7
8 import math
9 import os
10 import shutil
11 import sys
12
13 import PyOpenColorIO as ocio
14
15 import aces_ocio.create_aces_colorspaces as aces
16 import aces_ocio.create_arri_colorspaces as arri
17 import aces_ocio.create_canon_colorspaces as canon
18 import aces_ocio.create_red_colorspaces as red
19 import aces_ocio.create_sony_colorspaces as sony
20 import aces_ocio.create_general_colorspaces as general
21
22 from aces_ocio.generate_lut import (
23     generate_1d_LUT_from_CTL,
24     generate_3d_LUT_from_CTL,
25     write_SPI_1d)
26 from aces_ocio.process import Process
27 from aces_ocio.utilities import ColorSpace, mat44_from_mat33, sanitize_path, compact
28
29 __author__ = 'ACES Developers'
30 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
31 __license__ = ''
32 __maintainer__ = 'ACES Developers'
33 __email__ = 'aces@oscars.org'
34 __status__ = 'Production'
35
36 __all__ = ['ACES_OCIO_CTL_DIRECTORY_ENVIRON',
37            'ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON',
38            'set_config_default_roles',
39            'write_config',
40            'generate_OCIO_transform',
41            'create_config',
42            'generate_LUTs',
43            'generate_baked_LUTs',
44            'create_config_dir',
45            'create_ACES_config',
46            'main']
47
48 ACES_OCIO_CTL_DIRECTORY_ENVIRON = 'ACES_OCIO_CTL_DIRECTORY'
49 ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON = 'ACES_OCIO_CONFIGURATION_DIRECTORY'
50
51
52 def set_config_default_roles(config,
53                              color_picking='',
54                              color_timing='',
55                              compositing_log='',
56                              data='',
57                              default='',
58                              matte_paint='',
59                              reference='',
60                              scene_linear='',
61                              texture_paint=''):
62     """
63     Sets given *OCIO* configuration default roles.
64
65     Parameters
66     ----------
67     config : config
68         *OCIO* configuration.
69     color_picking : str or unicode
70         Color picking role title.
71     color_timing : str or unicode
72         Color timing role title.
73     compositing_log : str or unicode
74         Compositing log role title.
75     data : str or unicode
76         Data role title.
77     default : str or unicode
78         Default role title.
79     matte_paint : str or unicode
80         Matte painting role title.
81     reference : str or unicode
82         Reference role title.
83     scene_linear : str or unicode
84         Scene linear role title.
85     texture_paint : str or unicode
86         Texture painting role title.
87
88     Returns
89     -------
90     bool
91          Definition success.
92     """
93
94     if color_picking:
95         config.setRole(ocio.Constants.ROLE_COLOR_PICKING, color_picking)
96     if color_timing:
97         config.setRole(ocio.Constants.ROLE_COLOR_TIMING, color_timing)
98     if compositing_log:
99         config.setRole(ocio.Constants.ROLE_COMPOSITING_LOG, compositing_log)
100     if data:
101         config.setRole(ocio.Constants.ROLE_DATA, data)
102     if default:
103         config.setRole(ocio.Constants.ROLE_DEFAULT, default)
104     if matte_paint:
105         config.setRole(ocio.Constants.ROLE_MATTE_PAINT, matte_paint)
106     if reference:
107         config.setRole(ocio.Constants.ROLE_REFERENCE, reference)
108     if scene_linear:
109         config.setRole(ocio.Constants.ROLE_SCENE_LINEAR, scene_linear)
110     if texture_paint:
111         config.setRole(ocio.Constants.ROLE_TEXTURE_PAINT, texture_paint)
112
113     return True
114
115
116 def write_config(config, config_path, sanity_check=True):
117     """
118     Writes the configuration to given path.
119
120     Parameters
121     ----------
122     parameter : type
123         Parameter description.
124
125     Returns
126     -------
127     type
128          Return value description.
129     """
130
131     if sanity_check:
132         try:
133             config.sanityCheck()
134         except Exception, e:
135             print e
136             print 'Configuration was not written due to a failed Sanity Check'
137             return
138
139     with open(config_path, mode='w') as fp:
140         fp.write(config.serialize())
141
142
143 def generate_OCIO_transform(transforms):
144     """
145     Object description.
146
147     Parameters
148     ----------
149     parameter : type
150         Parameter description.
151
152     Returns
153     -------
154     type
155          Return value description.
156     """
157
158     interpolation_options = {
159         'linear': ocio.Constants.INTERP_LINEAR,
160         'nearest': ocio.Constants.INTERP_NEAREST,
161         'tetrahedral': ocio.Constants.INTERP_TETRAHEDRAL
162     }
163     direction_options = {
164         'forward': ocio.Constants.TRANSFORM_DIR_FORWARD,
165         'inverse': ocio.Constants.TRANSFORM_DIR_INVERSE
166     }
167
168     ocio_transforms = []
169
170     for transform in transforms:
171
172         # lutFile transform
173         if transform['type'] == 'lutFile':
174             ocio_transform = ocio.FileTransform(
175                 src=transform['path'],
176                 interpolation=interpolation_options[
177                     transform['interpolation']],
178                 direction=direction_options[transform['direction']])
179             ocio_transforms.append(ocio_transform)
180         
181         # matrix transform
182         elif transform['type'] == 'matrix':
183             ocio_transform = ocio.MatrixTransform()
184             # MatrixTransform member variables can't be initialized directly.
185             # Each must be set individually.
186             ocio_transform.setMatrix(transform['matrix'])
187
188             if 'offset' in transform:
189                 ocio_transform.setOffset(transform['offset'])
190
191             if 'direction' in transform:
192                 ocio_transform.setDirection(
193                     direction_options[transform['direction']])
194
195             ocio_transforms.append(ocio_transform)
196
197         # exponent transform
198         elif transform['type'] == 'exponent':
199             ocio_transform = ocio.ExponentTransform()
200             ocio_transform.setValue(transform['value'])
201             ocio_transforms.append(ocio_transform)
202
203         # log transform
204         elif transform['type'] == 'log':
205             ocio_transform = ocio.LogTransform(
206                 base=transform['base'],
207                 direction=direction_options[transform['direction']])
208
209             ocio_transforms.append(ocio_transform)
210
211         # color space transform
212         elif transform['type'] == 'colorspace':
213             ocio_transform = ocio.ColorSpaceTransform( src=transform['src'],
214                 dst=transform['dst'],
215                 direction=direction_options['forward'] )
216             ocio_transforms.append(ocio_transform)
217
218         # unknown type
219         else:
220             print("Ignoring unknown transform type : %s" % transform['type'])
221
222     if len(ocio_transforms) > 1:
223         group_transform = ocio.GroupTransform()
224         for transform in ocio_transforms:
225             group_transform.push_back(transform)
226         transform = group_transform
227     else:
228         transform = ocio_transforms[0]
229
230     return transform
231
232 def add_colorspace_alias(config, reference_colorspace, colorspace, colorspace_alias_names):
233     """
234     Object description.
235
236     Parameters
237     ----------
238     parameter : type
239         Parameter description.
240
241     Returns
242     -------
243     type
244          Return value description.
245     """
246
247     for alias_name in colorspace_alias_names:
248         if alias_name == colorspace.name.lower():
249             return
250
251         print( "Adding alias colorspace space %s, alias to %s" % (
252             alias_name, colorspace.name))
253
254         compact_family_name = "Aliases"
255
256         ocio_colorspace_alias = ocio.ColorSpace(
257             name=alias_name,
258             bitDepth=colorspace.bit_depth,
259             description=colorspace.description,
260             equalityGroup=colorspace.equality_group,
261             family=compact_family_name,
262             isData=colorspace.is_data,
263             allocation=colorspace.allocation_type,
264             allocationVars=colorspace.allocation_vars)
265
266         if colorspace.to_reference_transforms != []:
267             print("Generating To-Reference transforms")
268             ocio_transform = generate_OCIO_transform([{
269                 'type': 'colorspace',
270                 'src': colorspace.name,
271                 'dst': reference_colorspace.name,
272                 'direction': 'forward'
273                 }])
274             ocio_colorspace_alias.setTransform(
275                 ocio_transform,
276                 ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
277
278         if colorspace.from_reference_transforms != []:
279             print("Generating From-Reference transforms")
280             ocio_transform = generate_OCIO_transform([{
281                 'type': 'colorspace',
282                 'src': reference_colorspace.name,
283                 'dst': colorspace.name,
284                 'direction': 'forward'
285                 }])
286             ocio_colorspace_alias.setTransform(
287                 ocio_transform,
288                 ocio.Constants.COLORSPACE_DIR_FROM_REFERENCE)
289
290         config.addColorSpace(ocio_colorspace_alias)
291
292
293 def create_config(config_data, nuke=False):
294     """
295     Object description.
296
297     Parameters
298     ----------
299     parameter : type
300         Parameter description.
301
302     Returns
303     -------
304     type
305          Return value description.
306     """
307
308     # Creating the *OCIO* configuration.
309     config = ocio.Config()
310
311     # Setting configuration overall values.
312     config.setDescription('An ACES config generated from python')
313     config.setSearchPath('luts')
314
315     # Defining the reference colorspace.
316     reference_data = config_data['referenceColorSpace']
317     print('Adding the reference color space : %s' % reference_data.name)
318
319     reference = ocio.ColorSpace(
320         name=reference_data.name,
321         bitDepth=reference_data.bit_depth,
322         description=reference_data.description,
323         equalityGroup=reference_data.equality_group,
324         family=reference_data.family,
325         isData=reference_data.is_data,
326         allocation=reference_data.allocation_type,
327         allocationVars=reference_data.allocation_vars)
328
329     config.addColorSpace(reference)
330
331     # Add alias
332     if reference_data.aliases != []:
333         add_colorspace_alias(config, reference_data,
334             reference_data, reference_data.aliases)
335
336     print("")
337
338     # Creating the remaining colorspaces.
339     for colorspace in sorted(config_data['colorSpaces']):
340         print('Creating new color space : %s' % colorspace.name)
341
342         ocio_colorspace = ocio.ColorSpace(
343             name=colorspace.name,
344             bitDepth=colorspace.bit_depth,
345             description=colorspace.description,
346             equalityGroup=colorspace.equality_group,
347             family=colorspace.family,
348             isData=colorspace.is_data,
349             allocation=colorspace.allocation_type,
350             allocationVars=colorspace.allocation_vars)
351
352         if colorspace.to_reference_transforms:
353             print('Generating To-Reference transforms')
354             ocio_transform = generate_OCIO_transform(
355                 colorspace.to_reference_transforms)
356             ocio_colorspace.setTransform(
357                 ocio_transform,
358                 ocio.Constants.COLORSPACE_DIR_TO_REFERENCE)
359
360         if colorspace.from_reference_transforms:
361             print('Generating From-Reference transforms')
362             ocio_transform = generate_OCIO_transform(
363                 colorspace.from_reference_transforms)
364             ocio_colorspace.setTransform(
365                 ocio_transform,
366                 ocio.Constants.COLORSPACE_DIR_FROM_REFERENCE)
367
368         config.addColorSpace(ocio_colorspace)
369
370         #
371         # Add alias to normal colorspace, using compact name
372         #
373         if colorspace.aliases != []:
374             add_colorspace_alias(config, reference_data, 
375                 colorspace, colorspace.aliases)
376
377         print('')
378
379     # Defining the *views* and *displays*.
380     displays = []
381     views = []
382
383     # Defining a *generic* *display* and *view* setup.
384     if not nuke:
385         for display, view_list in config_data['displays'].iteritems():
386             for view_name, colorspace in view_list.iteritems():
387                 config.addDisplay(display, view_name, colorspace.name)
388                 if not (view_name in views):
389                     views.append(view_name)
390             displays.append(display)
391
392     # Defining the *Nuke* specific set of *views* and *displays*.
393     else:
394         for display, view_list in config_data['displays'].iteritems():
395             for view_name, colorspace in view_list.iteritems():
396                 if view_name == 'Output Transform':
397                     view_name = 'View'
398                     config.addDisplay(display, view_name, colorspace.name)
399                     if not (view_name in views):
400                         views.append(view_name)
401             displays.append(display)
402
403         linear_display_space_name = config_data['linearDisplaySpace'].name
404         log_display_space_name = config_data['logDisplaySpace'].name
405
406         config.addDisplay('linear', 'View', linear_display_space_name)
407         displays.append('linear')
408         config.addDisplay('log', 'View', log_display_space_name)
409         displays.append('log')
410
411     # Setting the active *displays* and *views*.
412     config.setActiveDisplays(','.join(sorted(displays)))
413     config.setActiveViews(','.join(views))
414
415     set_config_default_roles(
416         config,
417         color_picking=reference.getName(),
418         color_timing=reference.getName(),
419         compositing_log=reference.getName(),
420         data=reference.getName(),
421         default=reference.getName(),
422         matte_paint=reference.getName(),
423         reference=reference.getName(),
424         scene_linear=reference.getName(),
425         texture_paint=reference.getName())
426
427     config.sanityCheck()
428
429     return config
430
431 def generate_LUTs(odt_info,
432                   lmt_info,
433                   shaper_name,
434                   aces_CTL_directory,
435                   lut_directory,
436                   lut_resolution_1d=4096,
437                   lut_resolution_3d=64,
438                   cleanup=True):
439     """
440     Object description.
441
442     Parameters
443     ----------
444     parameter : type
445         Parameter description.
446
447     Returns
448     -------
449     dict
450          Colorspaces and transforms converting between those colorspaces and
451          the reference colorspace, *ACES*.
452     """
453
454     print('generateLUTs - begin')
455     config_data = {}
456
457     # Initialize a few variables
458     config_data['displays'] = {}
459     config_data['colorSpaces'] = []
460
461     # -------------------------------------------------------------------------
462     # *ACES Color Spaces*
463     # -------------------------------------------------------------------------
464
465     # *ACES* colorspaces
466     (aces_reference,
467      aces_colorspaces, 
468      aces_displays,
469      aces_log_display_space) = aces.create_colorspaces(aces_CTL_directory,
470                                                        lut_directory, 
471                                                        lut_resolution_1d,
472                                                        lut_resolution_3d,
473                                                        lmt_info,
474                                                        odt_info,
475                                                        shaper_name,
476                                                        cleanup)
477
478     config_data['referenceColorSpace'] = aces_reference
479
480     for cs in aces_colorspaces:
481         config_data['colorSpaces'].append(cs)
482
483     for name, data in aces_displays.iteritems():
484         config_data['displays'][name] = data
485
486     config_data['linearDisplaySpace'] = aces_reference
487     config_data['logDisplaySpace'] = aces_log_display_space
488
489     # -------------------------------------------------------------------------
490     # *Camera Input Transforms*
491     # -------------------------------------------------------------------------
492
493     # *Log-C* to *ACES*.
494     arri_colorSpaces = arri.create_colorspaces(lut_directory,
495                                                lut_resolution_1d)
496     for cs in arri_colorSpaces:
497         config_data['colorSpaces'].append(cs)
498
499     # *Canon-Log* to *ACES*.
500     canon_colorspaces = canon.create_colorspaces(lut_directory,
501                                                  lut_resolution_1d)
502     for cs in canon_colorspaces:
503         config_data['colorSpaces'].append(cs)
504
505     # *RED* colorspaces to *ACES*.
506     red_colorspaces = red.create_colorspaces(lut_directory, 
507                                              lut_resolution_1d)
508     for cs in red_colorspaces:
509         config_data['colorSpaces'].append(cs)
510
511     # *S-Log* to *ACES*.
512     sony_colorSpaces = sony.create_colorspaces(lut_directory,
513                                                lut_resolution_1d)
514     for cs in sony_colorSpaces:
515         config_data['colorSpaces'].append(cs)
516
517     # -------------------------------------------------------------------------
518     # General Color Spaces
519     # -------------------------------------------------------------------------
520     general_colorSpaces = general.create_colorspaces(lut_directory,
521                                                      lut_resolution_1d,
522                                                      lut_resolution_3d)
523     for cs in general_colorSpaces:
524         config_data['colorSpaces'].append(cs)
525
526     print('generateLUTs - end')
527     return config_data
528
529
530 def generate_baked_LUTs(odt_info,
531                         shaper_name,
532                         baked_directory,
533                         config_path,
534                         lut_resolution_1d,
535                         lut_resolution_3d,
536                         lut_resolution_shaper=1024):
537     """
538     Object description.
539
540     Parameters
541     ----------
542     parameter : type
543         Parameter description.
544
545     Returns
546     -------
547     type
548          Return value description.
549     """
550
551     # Create two entries for ODTs that have full and legal range support
552     odt_info_C = dict(odt_info)
553     for odt_CTL_name, odt_values in odt_info.iteritems():
554         if odt_values['transformHasFullLegalSwitch']:
555             odt_name = odt_values['transformUserName']
556
557             odt_values_legal = dict(odt_values)
558             odt_values_legal['transformUserName'] = '%s - Legal' % odt_name
559             odt_info_C['%s - Legal' % odt_CTL_name] = odt_values_legal
560
561             odt_values_full = dict(odt_values)
562             odt_values_full['transformUserName'] = '%s - Full' % odt_name
563             odt_info_C['%s - Full' % odt_CTL_name] = odt_values_full
564
565             del (odt_info_C[odt_CTL_name])
566
567     # Generate appropriate LUTs for each ODT
568     for odt_CTL_name, odt_values in odt_info_C.iteritems():
569         odt_prefix = odt_values['transformUserNamePrefix']
570         odt_name = odt_values['transformUserName']
571
572         # *Photoshop*
573         for input_space in ['ACEScc', 'ACESproxy']:
574             args = ['--iconfig', config_path,
575                     '-v',
576                     '--inputspace', input_space]
577             args += ['--outputspace', '%s' % odt_name]
578             args += ['--description',
579                      '%s - %s for %s data' % (odt_prefix,
580                                               odt_name,
581                                               input_space)]
582             args += ['--shaperspace', shaper_name,
583                      '--shapersize', str(lut_resolution_shaper)]
584             args += ['--cubesize', str(lut_resolution_3d)]
585             args += ['--format',
586                      'icc',
587                      os.path.join(baked_directory,
588                                   'photoshop',
589                                   '%s for %s.icc' % (odt_name, input_space))]
590
591             bake_LUT = Process(description='bake a LUT',
592                                cmd='ociobakelut',
593                                args=args)
594             bake_LUT.execute()
595
596         # *Flame*, *Lustre*
597         for input_space in ['ACEScc', 'ACESproxy']:
598             args = ['--iconfig', config_path,
599                     '-v',
600                     '--inputspace', input_space]
601             args += ['--outputspace', '%s' % odt_name]
602             args += ['--description',
603                      '%s - %s for %s data' % (
604                          odt_prefix, odt_name, input_space)]
605             args += ['--shaperspace', shaper_name,
606                      '--shapersize', str(lut_resolution_shaper)]
607             args += ['--cubesize', str(lut_resolution_3d)]
608
609             fargs = ['--format',
610                      'flame',
611                      os.path.join(
612                          baked_directory,
613                          'flame',
614                          '%s for %s Flame.3dl' % (odt_name, input_space))]
615             bake_LUT = Process(description='bake a LUT',
616                                cmd='ociobakelut',
617                                args=(args + fargs))
618             bake_LUT.execute()
619
620             largs = ['--format',
621                      'lustre',
622                      os.path.join(
623                          baked_directory,
624                          'lustre',
625                          '%s for %s Lustre.3dl' % (odt_name, input_space))]
626             bake_LUT = Process(description='bake a LUT',
627                                cmd='ociobakelut',
628                                args=(args + largs))
629             bake_LUT.execute()
630
631         # *Maya*, *Houdini*
632         for input_space in ['ACEScg', 'ACES2065-1']:
633             args = ['--iconfig', config_path,
634                     '-v',
635                     '--inputspace', input_space]
636             args += ['--outputspace', '%s' % odt_name]
637             args += ['--description',
638                      '%s - %s for %s data' % (
639                          odt_prefix, odt_name, input_space)]
640             if input_space == 'ACEScg':
641                 lin_shaper_name = '%s - AP1' % shaper_name
642             else:
643                 lin_shaper_name = shaper_name
644             args += ['--shaperspace', lin_shaper_name,
645                      '--shapersize', str(lut_resolution_shaper)]
646
647             args += ['--cubesize', str(lut_resolution_3d)]
648
649             margs = ['--format',
650                      'cinespace',
651                      os.path.join(
652                          baked_directory,
653                          'maya',
654                          '%s for %s Maya.csp' % (odt_name, input_space))]
655             bake_LUT = Process(description='bake a LUT',
656                                cmd='ociobakelut',
657                                args=(args + margs))
658             bake_LUT.execute()
659
660             hargs = ['--format',
661                      'houdini',
662                      os.path.join(
663                          baked_directory,
664                          'houdini',
665                          '%s for %s Houdini.lut' % (odt_name, input_space))]
666             bake_LUT = Process(description='bake a LUT',
667                                cmd='ociobakelut',
668                                args=(args + hargs))
669             bake_LUT.execute()
670
671
672 def create_config_dir(config_directory, bake_secondary_LUTs):
673     """
674     Object description.
675
676     Parameters
677     ----------
678     parameter : type
679         Parameter description.
680
681     Returns
682     -------
683     type
684          Return value description.
685     """
686
687     lut_directory = os.path.join(config_directory, 'luts')
688     dirs = [config_directory, lut_directory]
689     if bake_secondary_LUTs:
690         dirs.extend([os.path.join(config_directory, 'baked'),
691                      os.path.join(config_directory, 'baked', 'flame'),
692                      os.path.join(config_directory, 'baked', 'photoshop'),
693                      os.path.join(config_directory, 'baked', 'houdini'),
694                      os.path.join(config_directory, 'baked', 'lustre'),
695                      os.path.join(config_directory, 'baked', 'maya')])
696
697     for d in dirs:
698         not os.path.exists(d) and os.mkdir(d)
699
700     return lut_directory
701
702 def create_ACES_config(aces_CTL_directory,
703                        config_directory,
704                        lut_resolution_1d=4096,
705                        lut_resolution_3d=64,
706                        bake_secondary_LUTs=True,
707                        cleanup=True):
708     """
709     Creates the ACES configuration.
710
711     Parameters
712     ----------
713     parameter : type
714         Parameter description.
715
716     Returns
717     -------
718     type
719          Return value description.
720     """
721
722     lut_directory = create_config_dir(config_directory, bake_secondary_LUTs)
723
724     odt_info = aces.get_ODT_info(aces_CTL_directory)
725     lmt_info = aces.get_LMT_info(aces_CTL_directory)
726
727     shaper_name = 'Output Shaper'
728     config_data = generate_LUTs(odt_info,
729                                 lmt_info,
730                                 shaper_name,
731                                 aces_CTL_directory,
732                                 lut_directory,
733                                 lut_resolution_1d,
734                                 lut_resolution_3d,
735                                 cleanup)
736
737     print('Creating "generic" config')
738     config = create_config(config_data)
739     print('\n\n\n')
740
741     write_config(config,
742                  os.path.join(config_directory, 'config.ocio'))
743
744     print('Creating "Nuke" config')
745     nuke_config = create_config(config_data, nuke=True)
746     print('\n\n\n')
747
748     write_config(nuke_config,
749                  os.path.join(config_directory, 'nuke_config.ocio'))
750
751     if bake_secondary_LUTs:
752         generate_baked_LUTs(odt_info,
753                             shaper_name,
754                             os.path.join(config_directory, 'baked'),
755                             os.path.join(config_directory, 'config.ocio'),
756                             lut_resolution_1d,
757                             lut_resolution_3d,
758                             lut_resolution_1d)
759
760     return True
761
762
763 def main():
764     """
765     Object description.
766
767     Parameters
768     ----------
769     parameter : type
770         Parameter description.
771
772     Returns
773     -------
774     type
775          Return value description.
776     """
777
778     import optparse
779
780     p = optparse.OptionParser(description='An OCIO config generation script',
781                               prog='createACESConfig',
782                               version='createACESConfig 0.1',
783                               usage='%prog [options]')
784     p.add_option('--acesCTLDir', '-a', default=os.environ.get(
785         ACES_OCIO_CTL_DIRECTORY_ENVIRON, None))
786     p.add_option('--configDir', '-c', default=os.environ.get(
787         ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON, None))
788     p.add_option('--lutResolution1d', default=4096)
789     p.add_option('--lutResolution3d', default=64)
790     p.add_option('--dontBakeSecondaryLUTs', action='store_true')
791     p.add_option('--keepTempImages', action='store_true')
792
793     options, arguments = p.parse_args()
794
795     aces_CTL_directory = options.acesCTLDir
796     config_directory = options.configDir
797     lut_resolution_1d = int(options.lutResolution1d)
798     lut_resolution_3d = int(options.lutResolution3d)
799     bake_secondary_LUTs = not options.dontBakeSecondaryLUTs
800     cleanup_temp_images = not options.keepTempImages
801
802     # TODO: Investigate the following statements.
803     try:
804         args_start = sys.argv.index('--') + 1
805         args = sys.argv[args_start:]
806     except:
807         args_start = len(sys.argv) + 1
808         args = []
809
810     print('command line : \n%s\n' % ' '.join(sys.argv))
811
812     assert aces_CTL_directory is not None, (
813         'process: No "{0}" environment variable defined or no "ACES CTL" '
814         'directory specified'.format(
815             ACES_OCIO_CTL_DIRECTORY_ENVIRON))
816
817     assert config_directory is not None, (
818         'process: No "{0}" environment variable defined or no configuration '
819         'directory specified'.format(
820             ACES_OCIO_CONFIGURATION_DIRECTORY_ENVIRON))
821
822     return create_ACES_config(aces_CTL_directory,
823                               config_directory,
824                               lut_resolution_1d,
825                               lut_resolution_3d,
826                               bake_secondary_LUTs,
827                               cleanup_temp_images)
828
829
830 if __name__ == '__main__':
831     main()