set default file output to EXR multilayer

1.6.2

- changed: Default fileout format changed from `OPEN_EXR` to `OPEN_EXR_MULTILAYER` (a `FILE_FORMAT` env variable can be set to specify nodes format)
- changed: Default compression changed from `ZIP` to `PIZ`
- changed: Rename/renumber function consider OPEN_EXR_MULTILAYER to affect `layer_slots` instead of `file_slots`
This commit is contained in:
pullusb
2024-02-22 17:29:41 +01:00
parent 9820f273c2
commit b973668f02
4 changed files with 41 additions and 16 deletions
+31 -11
View File
@@ -150,12 +150,15 @@ def copy_settings(obj_a, obj_b):
pass
def set_file_output_format(fo):
fo.format.file_format = 'OPEN_EXR'
# FIXME for now default fallback to multilayer
env_file_format = os.environ.get('FILE_FORMAT')
fo.format.file_format = env_file_format if env_file_format else 'OPEN_EXR_MULTILAYER'
# fo.format.file_format = 'OPEN_EXR' # 'OPEN_EXR_MULTILAYER'
fo.format.color_mode = 'RGBA'
fo.format.color_depth = '16'
fo.format.exr_codec = 'ZIP'
# fo.format.exr_codec = 'RLE'
fo.format.exr_codec = 'PIZ' # 'ZIP', 'RLE'
## PNG format
# fo.format.file_format = 'PNG'
# fo.format.color_mode = 'RGBA'
# fo.format.color_depth = '8'
@@ -898,21 +901,26 @@ def get_numbered_output(out, slot_name):
def add_fileslot_number(fs, number):
elems = fs.path.split('/')
field_attr = 'name' if hasattr(fs, 'name') else 'path'
elems = getattr(fs, field_attr).split('/')
for i, e in enumerate(elems):
if re.match(r'^\d{3}_', e):
elems[i] = re.sub(r'^(\d{3})', lambda x: str(number).zfill(3), e)
else:
elems[i] = f'{str(number).zfill(3)}_{e}'
new = '/'.join(elems)
fs.path = new
setattr(fs, field_attr, new)
return new
def renumber(fo, offset=10):
'''Force renumber all the slots with a 3'''
if fo.type != 'OUTPUT_FILE': return
ct = 10 # start at 10
for fs in fo.file_slots:
slots = fo.layer_slots if fo.format.file_format == 'OPEN_EXR_MULTILAYER' else fo.file_slots
for fs in slots:
add_fileslot_number(fs, ct)
ct += offset
@@ -921,7 +929,11 @@ def get_num(string) -> int:
return leading number or None
'''
if not isinstance(string, str):
string = string.path
if hasattr(string, 'path'):
string = string.path
else:
string = string.name
num = re.search(r'^(\d{3})_', string)
if num:
return int(num.group(1))
@@ -930,13 +942,21 @@ def delete_numbering(fo): # padding=3
'''Delete prefix numbering on all slots on passed file output'''
if fo.type != 'OUTPUT_FILE': return
for fs in fo.file_slots:
elems = fs.path.split('/')
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
slots = fo.layer_slots
field_attr = 'name'
else:
slots = fo.file_slots
field_attr = 'path'
for fs in slots:
elems = getattr(fs, field_attr).split('/')
for i, e in enumerate(elems):
elems[i] = re.sub(r'^\d{3}_', '', e)
new = '/'.join(elems)
fs.path = new
setattr(fs, field_attr, new)
def reverse_fileout_inputs(fo):
count = len(fo.inputs)
@@ -954,7 +974,7 @@ def renumber_keep_existing(fo, offset=10, invert=True):
if invert:
reverse_fileout_inputs(fo)
fsl = fo.file_slots
fsl = fo.layer_slots if fo.format.file_format == 'OPEN_EXR_MULTILAYER' else fo.file_slots
last_idx = len(fsl) - 1
prev = None