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

Resize not working #272

Closed
0xn3bs opened this issue Mar 9, 2016 · 10 comments
Closed

Resize not working #272

0xn3bs opened this issue Mar 9, 2016 · 10 comments

Comments

@0xn3bs
Copy link

0xn3bs commented Mar 9, 2016

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?

@0xn3bs
Copy link
Author

0xn3bs commented Mar 9, 2016

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.

@Leif0
Copy link

Leif0 commented Mar 27, 2016

Same issue.

Is there another way to resize?

@ttback
Copy link

ttback commented Apr 2, 2016

@Leif0 Moviepy only works up to Pillow 2.9.0.
Try to pip install pillow==2.9.0 will fix this problem for now.

@jeflopodev
Copy link

Workaround:
As suggested by @inkadnb, just change line 32 .tostring() to .tobytes()

Lib\site-packages\moviepy\video\fx\resize.py
Line 32: arr = np.fromstring(resized_pil.tobytes(), dtype='uint8')

@craiglytle
Copy link

craiglytle commented Sep 8, 2016

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

@Zulko
Copy link
Owner

Zulko commented Sep 13, 2016

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 !

@robolivable
Copy link

Will a version with the fix for this get pushed to PyPI sometime soon?

@keikoro
Copy link
Collaborator

keikoro commented Feb 19, 2017

@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.

@craiglytle
Copy link

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.

@keikoro
Copy link
Collaborator

keikoro commented Feb 20, 2017

Great, thanks, @craiglytle! In that case I'll close the issue.

@keikoro keikoro closed this as completed Feb 20, 2017
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

8 participants