[Python] Moviepy - Resizing Imageclip to Textclip

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to be my moviepy to fit text to a rectangular background png. Currently I am creating a ImageClip that uses a png.

    titlecard = (
    ImageClip( os.getenv('TITLEFILE') )
    .with_position(("center","center"))
    )


    Then I create a text clip that should fill in the png. But it comes out looking very odd. The Text doesn't fill the space of the png it just wraps to a new line if it has too. Meaning there is a lot of dead space above and below the text.

    TextClip
    (
    text=title,
    stroke_width = stroke_width,
    size=size,
    method='caption',
    ).with_position(position)


    The title length can be very long or very small, this varies every time I will run this program.

    I am thinking that I should first create the TextClip and then resize the ImageClip to its size but I am not sure if this is possible or if there is a better way to go about solving this. I am also not sure if using label instead of caption would be better because then the text could be very small.

    Continue reading...

Compartilhe esta Página