Skip to content

Commit

Permalink
Call resize on mask when newsize is a function of time (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 authored May 29, 2020
1 parent fbec26a commit e8ce135
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `AudioFileClip` would not generate audio identical to the original file [#1108]
- Several issues resulting from incorrect time values due to floating point errors [#1195], for example:
- Blank frames at the end of clips [#210]
- Sometimes getting `IndexError: list index out of range` when using `concatenate_videoclips` [#646]
- Sometimes getting `IndexError: list index out of range` when using `concatenate_videoclips` [#646]
- Applying `resize` with a non-constant `newsize` to a clip with a mask would remove the mask [#1200]


## [v1.0.3](https://github.com/zulko/moviepy/tree/v1.0.3) (2020-05-07)
Expand Down
12 changes: 8 additions & 4 deletions moviepy/video/fx/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def trans_newsize(ns):
return ns

if hasattr(newsize, "__call__"):
# The resizing is a function of time

def newsize2(t):
return trans_newsize(newsize(t))
Expand All @@ -114,12 +115,15 @@ def fun(gf, t):
def fun(gf, t):
return resizer(gf(t).astype("uint8"), newsize2(t))

return clip.fl(
newclip = clip.fl(
fun, keep_duration=True, apply_to=(["mask"] if apply_to_mask else [])
)
if apply_to_mask and clip.mask is not None:
newclip.mask = resize(clip.mask, newsize, apply_to_mask=False)

else:
return newclip

else:
newsize = trans_newsize(newsize)

elif height is not None:
Expand All @@ -132,7 +136,6 @@ def fun(t):
return resize(clip, fun)

else:

newsize = [w * height / h, height]

elif width is not None:
Expand All @@ -144,7 +147,8 @@ def fun(t):

return resize(clip, fun)

newsize = [width, h * width / w]
else:
newsize = [width, h * width / w]

# From here, the resizing is constant (not a function of time), size=newsize

Expand Down

0 comments on commit e8ce135

Please sign in to comment.