You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of resize.py uses the deprecated PIL.Image.ANTIALIAS which was removed in newer versions of Pillow. This causes issues for users trying to use MoviePy with current Pillow versions.
Current Behavior
When trying to use the resize functionality with current Pillow versions (>=10.0.0), the following error occurs:
The resize functionality should work with current Pillow versions using the new Image.Resampling.LANCZOS instead of the deprecated ANTIALIAS.
Proposed Solution
Here's a proposed update to the resize implementation that maintains compatibility:
fromscipyimportndimageimportnumpyasnpfromPILimportImagedefresize(clip, newsize=None, height=None, width=None, apply_to_mask=True):
w, h=clip.sizeifnewsizeisnotNone:
w2, h2=newsizeelse:
ifwidthisnotNone:
w2=widthh2=int(h*width/w)
elifheightisnotNone:
h2=heightw2=int(w*height/h)
else:
raiseValueError("Either newsize, width, or height must be specified!")
# Method 1: Using scipy.ndimage (recommended for better performance)resized_clip=clip.fl_image(
lambdapic: ndimage.zoom(pic, [h2/h, w2/w, 1], order=1)
)
# Alternative Method 2: Using PIL with updated resampling""" def resize_frame(pic): pil_image = Image.fromarray(pic) resized_img = pil_image.resize((w2, h2), Image.Resampling.LANCZOS) return np.array(resized_img) resized_clip = clip.fl_image(resize_frame) """resized_clip.fps=clip.fpsresized_clip.duration=clip.durationresized_clip.end=clip.endreturnresized_clip
Additional Context
There are two proposed methods in the solution:
Using scipy.ndimage.zoom: Generally better performance for video processing
Using updated PIL resize: More compatible with image processing workflows
Temporary Workaround
For users encountering this issue, there are two temporary solutions:
Pin Pillow to version 9.5.0 (pip install Pillow==9.5.0)
Clone the repository and modify the resize.py file locally
Environment
MoviePy version: 1.0.3
Python version: 3.9+
Pillow version: 10.0.0+
Operating System: Tested on Windows, Linux
Impact
This affects all users trying to use MoviePy with current versions of Pillow, particularly in production environments where using older versions of dependencies isn't ideal.
Would appreciate feedback on the proposed solution or alternative approaches.
The text was updated successfully, but these errors were encountered:
Is there a workaround in the meantime that I can I use? I guess I can downgrade pillow.
Well downgrade your pillow version and it fixes the issue. Honestly for me i just gave up on moviepy, the workarounds are juat too much for my production grade application so ai went to react remotion because its just css bro
Description
The current implementation of
resize.py
uses the deprecatedPIL.Image.ANTIALIAS
which was removed in newer versions of Pillow. This causes issues for users trying to use MoviePy with current Pillow versions.Current Behavior
When trying to use the resize functionality with current Pillow versions (>=10.0.0), the following error occurs:
Expected Behavior
The resize functionality should work with current Pillow versions using the new
Image.Resampling.LANCZOS
instead of the deprecatedANTIALIAS
.Proposed Solution
Here's a proposed update to the resize implementation that maintains compatibility:
Additional Context
There are two proposed methods in the solution:
scipy.ndimage.zoom
: Generally better performance for video processingTemporary Workaround
For users encountering this issue, there are two temporary solutions:
pip install Pillow==9.5.0
)Environment
Impact
This affects all users trying to use MoviePy with current versions of Pillow, particularly in production environments where using older versions of dependencies isn't ideal.
Would appreciate feedback on the proposed solution or alternative approaches.
The text was updated successfully, but these errors were encountered: