Return value description.
"""
- f = file(filename, 'w')
- f.write('Version 1\n')
- f.write('From %f %f\n' % (from_min, from_max))
- f.write('Length %d\n' % entries)
- f.write('Components %d\n' % (min(3, channels)))
- f.write('{\n')
- for i in range(0, entries):
- entry = ''
- for j in range(0, min(3, channels)):
- entry = '%s %s' % (entry, data[i * channels + j])
- f.write(' %s\n' % entry)
- f.write('}\n')
- f.close()
+ with open(filename, 'w') as fp:
+ fp.write('Version 1\n')
+ fp.write('From %f %f\n' % (from_min, from_max))
+ fp.write('Length %d\n' % entries)
+ fp.write('Components %d\n' % (min(3, channels)))
+ fp.write('{\n')
+ for i in range(0, entries):
+ entry = ''
+ for j in range(0, min(3, channels)):
+ entry = '%s %s' % (entry, data[i * channels + j])
+ fp.write(' %s\n' % entry)
+ fp.write('}\n')
def generate_1d_LUT_from_image(ramp_1d_path,
"""
if output_path is None:
- output_path = ramp_1d_path + '.spi1d'
+ output_path = '%s.%s' % (ramp_1d_path, 'spi1d')
# open image
ramp = oiio.ImageInput.open(ramp_1d_path)
"""
if output_path is None:
- output_path = ramp_3d_path + '.spi3d'
+ output_path = '%s.%s' % (ramp_3d_path, 'spi1d')
args = ['--extract',
'--cubesize',
ctlenv = os.environ
if aces_CTL_directory != None:
if os.path.split(aces_CTL_directory)[1] != 'utilities':
- ctl_module_path = '%s/utilities' % aces_CTL_directory
+ ctl_module_path = os.path.join(aces_CTL_directory, 'utilities')
else:
ctl_module_path = aces_CTL_directory
ctlenv['CTL_MODULE_PATH'] = ctl_module_path
lut_path_base = os.path.splitext(lut_path)[0]
- identity_LUT_image_float = lut_path_base + '.float.tiff'
+ identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
generate_1d_LUT_image(identity_LUT_image_float,
lut_resolution,
min_value,
max_value)
if identity_LUT_bit_depth != 'half':
- identity_LUT_image = lut_path_base + '.uint16.tiff'
+ identity_LUT_image = '%s.%s.%s' % (lut_path_base, 'uint16', 'tiff')
convert_bit_depth(identity_LUT_image_float,
identity_LUT_image,
identity_LUT_bit_depth)
else:
identity_LUT_image = identity_LUT_image_float
- transformed_LUT_image = lut_path_base + '.transformed.exr'
+ transformed_LUT_image = '%s.%s.%s' % (lut_path_base, 'transformed', 'exr')
apply_CTL_to_image(identity_LUT_image,
transformed_LUT_image,
ctl_paths,
lut_path_base = os.path.splitext(lut_path)[0]
- identity_LUT_image_float = lut_path_base + '.float.tiff'
+ identity_LUT_image_float = '%s.%s.%s' % (lut_path_base, 'float', 'tiff')
generate_3d_LUT_image(identity_LUT_image_float, lut_resolution)
if identity_LUT_bit_depth != 'half':
- identity_LUT_image = (lut_path_base +
- '.' +
- identity_LUT_bit_depth +
- '.tiff')
+ identity_LUT_image = '%s.%s.%s' % (lut_path_base,
+ identity_LUT_bit_depth,
+ 'tiff')
convert_bit_depth(identity_LUT_image_float,
identity_LUT_image,
identity_LUT_bit_depth)
else:
identity_LUT_image = identity_LUT_image_float
- transformed_LUT_image = lut_path_base + '.transformed.exr'
+ transformed_LUT_image = '%s.%s.%s' % (lut_path_base, 'transformed', 'exr')
apply_CTL_to_image(identity_LUT_image,
transformed_LUT_image,
ctl_paths,
global_params,
aces_CTL_directory)
- corrected_LUT_image = lut_path_base + '.correct.exr'
+ corrected_LUT_image = '%s.%s.%s' % (lut_path_base, 'correct', 'exr')
corrected_LUT_image = correct_LUT_image(transformed_LUT_image,
corrected_LUT_image,
lut_resolution)