I want to modify every frame in an animation after it has been saved as an image. Since bpy.data.images["Render Result"] doesn't have associated data I need to load it from disk.

How do I get the path of the last rendered frame in a render_post handler?


3 Answers 3


The filepath is stored in:


However there is a function to find the output filename for a frame (the same function blender uses internally).

output = bpy.context.scene.render.frame_path(frame=10)

example use:

>>> bpy.context.scene.render.filepath = "/test/some_###_anim.png"
>>> bpy.context.scene.render.frame_path(frame=10)

You'll probably want to use context.scene.render.filepath and append the frame number with (using str.zfill(4) where str is the frame number as a string and 4 is the number of digits), and extension using context.scene.render.image_settings.file_format, converted to lower case (using str.lower()).

  • $\begingroup$ What about '#' in the output filepath? $\endgroup$
    – Maccesch
    Commented Oct 15, 2013 at 13:09
  • $\begingroup$ '#' indicates padding, so you could count the number of '#'s after the last slash (in case folder names have hashes) and use that instead of 4 $\endgroup$
    – Greg Zaal
    Commented Oct 15, 2013 at 13:25
  • $\begingroup$ You'd also have to remove the hashes from the output path using str.replace('#', '') $\endgroup$
    – Greg Zaal
    Commented Oct 15, 2013 at 13:32
  • $\begingroup$ Could you update your answer with a complete code example for all this please? $\endgroup$
    – Maccesch
    Commented Oct 15, 2013 at 13:39
  • 1
    $\begingroup$ Now that would make it too easy wouldn't it ;) Figuring it out by yourself will teach you something. If you're still stuck tomorrow then I'll code it for you. $\endgroup$
    – Greg Zaal
    Commented Oct 15, 2013 at 18:05

The expression you want is bpy.context.scene.render.frame_path()

Calling frame_path without specifying a frame uses the current frame.

import bpy

def handle_render_write(scn):


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .