Skip to content

Commit 8627f2a

Browse files
authored
fix(constants.py,image_mobject.py,opengl_image_mobject.py): Update deprecated pillow constants (#2715)
1 parent affc719 commit 8627f2a

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

manim/constants.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88
from cloup import Context
9-
from PIL import Image
9+
from PIL.Image import Resampling
1010

1111
__all__ = [
1212
"NOT_SETTING_FONT_MSG",
@@ -113,16 +113,16 @@
113113
ULTRAHEAVY: str = "ULTRAHEAVY"
114114

115115
RESAMPLING_ALGORITHMS = {
116-
"nearest": Image.NEAREST,
117-
"none": Image.NEAREST,
118-
"lanczos": Image.LANCZOS,
119-
"antialias": Image.LANCZOS,
120-
"bilinear": Image.BILINEAR,
121-
"linear": Image.BILINEAR,
122-
"bicubic": Image.BICUBIC,
123-
"cubic": Image.BICUBIC,
124-
"box": Image.BOX,
125-
"hamming": Image.HAMMING,
116+
"nearest": Resampling.NEAREST,
117+
"none": Resampling.NEAREST,
118+
"lanczos": Resampling.LANCZOS,
119+
"antialias": Resampling.LANCZOS,
120+
"bilinear": Resampling.BILINEAR,
121+
"linear": Resampling.BILINEAR,
122+
"bicubic": Resampling.BICUBIC,
123+
"cubic": Resampling.BICUBIC,
124+
"box": Resampling.BOX,
125+
"hamming": Resampling.HAMMING,
126126
}
127127

128128
# Geometry: directions

manim/mobject/opengl/opengl_image_mobject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import numpy as np
1010
from PIL import Image
11+
from PIL.Image import Resampling
1112

1213
from manim.mobject.opengl.opengl_surface import OpenGLSurface, OpenGLTexturedSurface
1314
from manim.utils.images import get_full_raster_image_path
@@ -20,7 +21,7 @@ def __init__(
2021
width: float = None,
2122
height: float = None,
2223
image_mode: str = "RGBA",
23-
resampling_algorithm: int = Image.BICUBIC,
24+
resampling_algorithm: int = Resampling.BICUBIC,
2425
opacity: float = 1,
2526
gloss: float = 0,
2627
shadow: float = 0,

manim/mobject/types/image_mobject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import colour
1010
import numpy as np
1111
from PIL import Image
12+
from PIL.Image import Resampling
1213

1314
from manim.mobject.geometry.shape_matchers import SurroundingRectangle
1415

@@ -38,7 +39,7 @@ def __init__(
3839
self,
3940
scale_to_resolution,
4041
pixel_array_dtype="uint8",
41-
resampling_algorithm=Image.BICUBIC,
42+
resampling_algorithm=Resampling.BICUBIC,
4243
**kwargs,
4344
):
4445
self.pixel_array_dtype = pixel_array_dtype

0 commit comments

Comments
 (0)