Isotropix Forums

Image "Save As" Path

Clarisse Scripting related topics

Image "Save As" Path

Unread postby briansilva » Tue Aug 13, 2019 10:31 am

Hello! This wouldn't be too hard to hack my way through, but is there an easy way to get a full file path for an Image's output?

I know I could take the format attribute, map the dropdown indices to extensions, parse the save_as attribute for ### tokens to generate the frame number, etc. But this is prone to issues (like which form of each extension does Clarisse use, for example).

Is there a quick/robust way to get this path in Python?
Posts: 70
Joined: Mon Mar 25, 2019 12:43 pm

Re: Image "Save As" Path

Unread postby dboude » Mon Aug 26, 2019 10:55 am


Do you mean something like that ?

Cheers ;)
Technical Artist - Clarisse Specialist
User avatar
Posts: 1603
Joined: Mon Jul 03, 2017 10:51 am

Re: Image "Save As" Path

Unread postby briansilva » Wed Sep 18, 2019 12:31 pm

Hey Démian,

Almost, but not quite -- that gives me all the paths, but for the output parameters, I still only get what the save_as parameter is literally set to.

So for example, this comes out of that script, from an Image:

But I'd like to get a full path to the actual full image path that will be rendered, like:

Which isn't too hard to figure out, but it requires me to do some parsing and make some assumptions about the extensions that Clarisse adds. I was hoping there was a way to use Clarisse's parsing (it must do it under the hood when the render runs) so I could trust that I'll always have the same path.
Posts: 70
Joined: Mon Mar 25, 2019 12:43 pm

Re: Image "Save As" Path

Unread postby anemoff » Thu Sep 19, 2019 10:20 am


There is a helper method to resolve the real filename, that we use internally, but sadly it isn't exposed in the Clarisse Python API.
So you need to write your own. Here is an example:

python code

import os
import re

def get_real_path(raw_file_path, file_ext, frame):
Evaluate the real file path from a raw file path containing a frame padding expression "####".
Note: this will replace only the 1st pattern occurence.
Example: "render_####.exr" at frame 42 will output "render_0042.exr"
# remove the extension if already set
file, _ = os.path.splitext(raw_file_path)

# search and replace the # pattern
match ='(#+)', file)
if not match:
# by default, Clarisse pads on 5 digits when no pattern is set
result = file + '{:05d}'.format(frame) + file_ext
return result
pattern_start = match.start(0)
pattern_length = match.end(0) - pattern_start
frame_str = '{:0{}d}'.format(frame, pattern_length)
result = file[:pattern_start] + frame_str + file[pattern_start + pattern_length:] + file_ext
return result

# Tests
print get_real_path('render', '.exr', 42)
print get_real_path('render.exr', '.exr', 42)
print get_real_path('render_##', '.exr', 42)
print get_real_path('render_##.exr', '.exr', 42)
print get_real_path('render_####', '.exr', 42)
print get_real_path('render_####_##', '.exr', 42)
print get_real_path('render_#####_extra', '.exr', 42)

Code: Select all

Anthony Nemoff
R&D Engineer
User avatar
Posts: 365
Joined: Wed Jan 13, 2016 10:10 am

Return to Scripting