rezoo/movis

Resizing Layers Properly

fly-qp opened this issue · 3 comments

fly-qp commented

Hello!
First of all i love this package and its really great work & super fast. Just one question since I could not find documentation on how to properly resize layers.
I found a workaround like the following:

image = mv.layer.Image(media_path, duration=duration)
scale_factor = helper.scale_to_cover(
    target_size=self.scene_size, current_size=image.size
)
scene = mv.layer.Composition(size=self.scene_size, duration=duration)
scene.add_layer(image, scale=scale_factor)


def scale_to_cover(target_size, current_size):
    tw, th = target_size
    cw, ch = current_size
    width_ratio = tw / cw
    height_ratio = th / ch
    return max(width_ratio, height_ratio)

But wouldn't it be more convenient having a function like ‘concatenate’ or ‘crop’, so we don't have to create a second layer?

rezoo commented

Thank you for your interest. As you mentioned, this type of resizing is typically done by specifying a scale_factor like in scene.add_layer(image, scale=scale_factor). We could also offer a shortcut function like mv.resize(), but the actual resizing speed does not seem to change much even if it is implemented.

Would this resize function be convenient if implemented?

fly-qp commented

Hey sorry for my late reply. I think it should be mentioned in the docs if possible since it's very common use case for basic video editing :)

rezoo commented

Thank you. I added the related description to README.md. If you have any other concerns, please do not hesitate to report them.