How do I set the read-only 'frame_duration' property of an image sequence with Python?
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