When I do a resize, I get the following stack trace:
Traceback (most recent call last):
File "\main.py", line 16, in <module>
videos = videoFactory.GenerateVideos()
File "\project\videoFactory.py", line 43, in GenerateVideos
textClip = fx.all.resize(textClip, newsize=0.5)
File "\env2.7\lib\site-packages\moviepy\video\fx\resize.py", line 144, in resize
newclip = clip.fl_image(fl)
File "<decorator-gen-68>", line 2, in fl_image
File "\env2.7\lib\site-packages\moviepy\decorators.py", line 14, in outplace
f(newclip, _a, *_k)
File "\env2.7\lib\site-packages\moviepy\video\VideoClip.py", line 942, in fl_image
arr = image_func(self.get_frame(0))
File "\env2.7\lib\site-packages\moviepy\video\fx\resize.py", line 142, in <lambda>
fl = lambda pic: resizer(pic.astype('uint8'), newsize)
File "\env2.7\lib\site-packages\moviepy\video\fx\resize.py", line 32, in resizer
arr = np.fromstring(resized_pil.tostring(), dtype='uint8')
File "\env2.7\lib\site-packages\PIL\Image.py", line 695, in tostring
"Please call tobytes() instead.")
Any idea what's going on?
I changed line 32 in resize.py to utilize tobytes instead of tostring and it fixed the problem. I'll submit a pull-request for this.
Same issue.
Is there another way to resize?
@Leif0 Moviepy only works up to Pillow 2.9.0.
Try to pip install pillow==2.9.0 will fix this problem for now.
Workaround:
As suggested by @inkadnb, just change line 32 .tostring() to .tobytes()
Libsite-packagesmoviepyvideofxresize.py
Line 32: arr = np.fromstring(resized_pil.tobytes(), dtype='uint8')
Just confirming that pull #301 solves the problem and it works with the latest Pillow. Thanks!
But the current release available via pip doesn't include this change and resize still fails with Pillow>=3.0. (I needed to use a recent Pillow for other reasons)
Any plans to add this change to the current release?
(By the way, moviepy is awesome)
@craiglytle
Thanks for this, I haven't done an update on pypi in a long time, very sorry. I'm very much under the water at the moment !
Will a version with the fix for this get pushed to PyPI sometime soon?
@craiglytle @robolivable It looks like the referenced PR was closed without getting merged, is this an ongoing issue? Because if so, I guess a fix would have to be resubmitted.
I just installed the moviepy 0.2.2.13 (pip install -upgrade moviepy), ran my basic test which uses resize with Pillow, and it looks great.
I can't recall the details of the resize/Pillow incompatibility issue from September, but I'm pretty sure that the master branch at the time solved the issue. I believe this was just an issue in whatever version was installed with pip at the time, but I'm not positive.
Let me know if there is anything I can do to help further.
Great, thanks, @craiglytle! In that case I'll close the issue.
Most helpful comment
Workaround:
As suggested by @inkadnb, just change line 32
.tostring()to.tobytes()Libsite-packagesmoviepyvideofxresize.py
Line 32:
arr = np.fromstring(resized_pil.tobytes(), dtype='uint8')