Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing Layers Properly #56

Open
fly-qp opened this issue Dec 22, 2023 · 3 comments
Open

Resizing Layers Properly #56

fly-qp opened this issue Dec 22, 2023 · 3 comments

Comments

@fly-qp
Copy link

fly-qp commented Dec 22, 2023

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
Copy link
Owner

rezoo commented Dec 23, 2023

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
Copy link
Author

fly-qp commented Dec 25, 2023

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
Copy link
Owner

rezoo commented Jan 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants