I’ve tried to do my due diligence and read up on conversion. There’s the pretty common register_module thing that now iterates over a bunch of classes for registration and so on. But when I try to update an older batch converter script from Tamir Lousky, I keep getting new issues since a lot of small things seem to have moved around the last 7 years or so.
This script lets you select a folder of exr files and you can then output them to another folder, to any format Blender supports. I want to batch compress exr files to exr DWAB in order to reduce size. If someone could update this script to Blender 3, I think a lot of people would find that useful.
I should probably have posted here to begin with. Step One would be to make this work in Blender 3+. Step Two would be if a few fresh sets of eyes could improve it further?
I’d appreciate any help!
ADDED: maybe I should clarify that this isn’t limited to exr. This script converts any folder of images to any of Blender’s supported formats. So a pretty convenient and “powerful” function/tool.
from source_folder = bpy.props.StringProperty
to source_folder: bpy.props.StringProperty
change “=” to “:” for each property declaration in property group.
Header bl_info:
"blender" : (3, 1, 0),
blender version must be same major version to load
Panel location:
bl_region_type = 'UI'
Recommended changes:
update class names to avoid warnings in background:
register_class(…):
Warning: ‘batch_converter’ does not contain ‘PT’ with prefix and suffix
create a list of classes for registration.
include del bpy.types.Scene.batch_convertor_properties in unregister to prevent properties being maintained in file if addon is unloaded.
classes = [
batchConverterProps,
batchConverterPanel,
batch_convert,
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.batch_convertor_properties = bpy.props.PointerProperty(
type = batchConverterProps
)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.Scene.batch_convertor_properties
Personally I would recommend just re-writing from scratch to do things like having the properties you want all in the same panel instead of making changes in render panel; adding the filter file type that was apparently never implemented; separating out some of the functions of the operator; etc.
Just to clarify: this isn’t my add-on, but something I found to solve a workflow “problem”. I have never written anything in Python or for Blender. I do have some general programming experience from Swift-development, but I don’t have any base to stand on for these add-ons. I can read and follow the code, but little things like indentation, commas and language conventions that I’m not familiar with throw me off.
I try to look at other plugins and piece things together that way.
When I have this up and running I’ll offer the working script here, as batch image conversion can always be useful. Ultimately, the hope is that someone finds this that agrees with its usefulness and that might be able to do some of that rewriting you suggest, including best practices.
Again, thanks for chiming in!
EDIT: Success!
So, I just compressed a folder of 205 .exr files with the DWAB compression and added a suffix automatically. Went from 54GB to 8.7GB.
Exactly what I was looking for. I’ll go over the code and see if there’s some remaining cleanup and then upload the updated version on GitHub.
Can you show us, where is the updated version on GitHub?
I have currently 50k frame of exrs from a lots of scenes, and it would be a HUGE help to me.
Thanks
You select the desired new format in Blender’s normal output settings. Then just point to you input folder and designate an output folder. Click ‘keep original resolution’ if you just want to compress images into another format. Then click the button that becomes active.
BE ADVICED: this was the most basic implementation that I made for myself and I would normally do further work before sharing. Please make sure you select another folder for your output images. Do not try to overwrite your original images in step one.
hi, thanks for the link.
Altough i’ve done everything as you said.
There was an PXR24 EXR seq in the source folder, i set the output settings to dwab, choose the destination folder. But it made a 4x4 size exr sequence with 8 channels, instead of 58 (The original exr sequence is 1920x1920 and has 58 channels)
Also the new exr seq file size was 1kb, all of them.
What did i miss? Sorry to bothering you with this kind of questions.