Skip to content

Video editing with Python

Correctly center image when resizing (#1420)

Jaclyn Brockschmidtdf973533db8b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99c1ae95..92864733 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,7 +25,8 @@ Lots of method and parameter names have been changed. This will be explained bet
### Fixed <!-- for any bug fixes -->
- Fixed BitmapClip with fps != 1 not returning the correct frames or crashing [#1333]
- Fixed `rotate` sometimes failing with `ValueError: axes don't match array` [#1335]
-- Changed deprecated `tostring` method by `tobytes` in `video.io.gif_writers::write_gif` #1429
+- Fixed positioning error generating frames in `CompositeVideoClip` [\#1420](https://github.com/Zulko/moviepy/pull/1420)
+- Changed deprecated `tostring` method by `tobytes` in `video.io.gif_writers::write_gif` [\#1429](https://github.com/Zulko/moviepy/pull/1429)
## [v2.0.0.dev2](https://github.com/zulko/moviepy/tree/v2.0.0.dev2) (2020-10-05)
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index 8ee8f10b..62d907fe 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -602,7 +602,7 @@ class VideoClip(Clip):
on the given `picture`, the position of the clip being given
by the clip's ``pos`` attribute. Meant for compositing.
"""
- hf, wf = picture.size
+ wf, hf = picture.size
ct = t - self.start # clip time
@@ -631,7 +631,7 @@ class VideoClip(Clip):
else:
im_mask = None
- hi, wi = im_img.size
+ wi, hi = im_img.size
# SET POSITION
pos = self.pos(ct)
diff --git a/moviepy/video/tools/drawing.py b/moviepy/video/tools/drawing.py
index d86ff158..59b150b1 100644
--- a/moviepy/video/tools/drawing.py
+++ b/moviepy/video/tools/drawing.py
@@ -12,13 +12,11 @@ def blit(im1, im2, pos=None, mask=None):
``mask`` if provided.
"""
if pos is None:
- pos = [0, 0]
-
- xp, yp = pos
- xp1 = max(0, xp)
- yp1 = max(0, yp)
-
- im2.paste(im1, (xp1, yp1), mask)
+ pos = (0, 0)
+ else:
+ # Cast to tuple in case pos is not subscriptable.
+ pos = tuple(pos)
+ im2.paste(im1, pos, mask)
return im2