I try to load in an image sequence as background image with python. I managed to load it and set the source as sequence, however when i try to set its frame duration according to the number of images in the sequence, I get an error saying that the attribute is read-only. Can I change this attribute in another way and if not, how can I tell Blender to use it as image sequence?

My code so far:

img = bpy.data.images.load(path)
img.source = "SEQUENCE"

Prints an error:

img.frame_duration = 50

Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
AttributeError: bpy_struct: attribute "frame_duration" from "Image" is read-

frame duration is a calculated value and cannot be set directly.

frame_duration = frame_end - frame_start

In order to change the frame_duration of the sequence you need to change the frame_start and/or frame_end. This makes sense as Blender cannot decide for you which frames you don't want to see (cut from the start or cut from the end, or from the middle, or ....).

# cut the start of the sequence
desired_frame_duration = 50
img.frame_start += img.frame_end - desired_frame_duration

# cut the end of the sequence
desired_frame_duration = 50
img.frame_end = img.frame_start + desired_frame_duration
| improve this answer | |
  • $\begingroup$ Seems the frame_start and frame_end no longer exist for image datablocks in Blender 2.8x. Is there another way this can be achieved? $\endgroup$ – Christopher Gearhart Sep 3 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.