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