diff --git a/CHANGELOG.md b/CHANGELOG.md index d7cf7f75a..d06ad23ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - When using `VideoClip.write_videofile()` with `write_logfile=True`, errors would not be properly reported [#890] - `TextClip.list("color")` now returns a list of bytes, not strings [#1119] - `TextClip.search("colorname", "color")` does not crash with a TypeError [#1119] +- Using `rotate()` with a `ColorClip` no longer crashes [#1139] ## [v1.0.2](https://github.com/zulko/moviepy/tree/v1.0.2) (2020-03-26) diff --git a/moviepy/video/fx/rotate.py b/moviepy/video/fx/rotate.py index e20623e70..3aeddba38 100644 --- a/moviepy/video/fx/rotate.py +++ b/moviepy/video/fx/rotate.py @@ -8,8 +8,11 @@ PIL_FOUND = True def pil_rotater(pic, angle, resample, expand): + # Ensures that pic is of the correct type return np.array( - Image.fromarray(pic).rotate(angle, expand=expand, resample=resample) + Image.fromarray(np.array(pic).astype(np.uint8)).rotate( + angle, expand=expand, resample=resample + ) ) diff --git a/tests/test_fx.py b/tests/test_fx.py index eb46b5ba7..8de4b6d27 100644 --- a/tests/test_fx.py +++ b/tests/test_fx.py @@ -6,6 +6,7 @@ from moviepy.audio.fx.audio_normalize import audio_normalize from moviepy.audio.io.AudioFileClip import AudioFileClip from moviepy.utils import close_all_clips +from moviepy.video.VideoClip import ColorClip from moviepy.video.fx.blackwhite import blackwhite # from moviepy.video.fx.blink import blink @@ -216,6 +217,15 @@ def test_rotate(): clip4 = rotate(clip, 360) # rotate 90 degrees assert clip4.size == tuple(clip.size) clip4.write_videofile(os.path.join(TMP_DIR, "rotate4.webm")) + + clip5 = rotate(clip, 50) + clip5.write_videofile(os.path.join(TMP_DIR, "rotate5.webm")) + + # Test rotate with color clip + clip = ColorClip([600, 400], [150, 250, 100]).set_duration(1).set_fps(5) + clip = rotate(clip, 20) + clip.write_videofile(os.path.join(TMP_DIR, "color_rotate.webm")) + close_all_clips(locals())