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
Support for specifying the interpolation algorithms for individual ImageMobjects (#1122)
* Adds support for specifying the interpolation algorithms for individual ImageMobjects.
* Remove setup.py
* Added a proper unit test
* Code formatting
* Adds Doc string
* Test rewritten by kolibril13
* Added control data to the test
* Replaces string resampling constants with Pillow integers; renames the constants into o 'resampling algorithms'
* Final 'nitpicks'
* ValueError update
* update example
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: kolibril13 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Copy file name to clipboardExpand all lines: manim/mobject/types/image_mobject.py
+65-1Lines changed: 65 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,16 @@ class AbstractImageMobject(Mobject):
30
30
This is a custom parameter of ImageMobject so that rendering a scene with e.g. the ``--quality low`` or ``--quality medium`` flag for faster rendering won't effect the position of the image on the screen.
Sets the interpolation method for upscaling the image. By default the image is interpolated using bicubic algorithm. This method lets you change it.
55
+
Interpolation is done internally using Pillow, and the function besides the string constants describing the algorithm accepts the Pillow integer constants.
56
+
57
+
Parameters
58
+
----------
59
+
resampling_algorithm : :class:`int`, an integer constant described in the Pillow library, or one from the RESAMPLING_ALGORITHMS global dictionary, under the following keys:
60
+
* 'bicubic' or 'cubic'
61
+
* 'nearest' or 'none'
62
+
* 'box'
63
+
* 'bilinear' or 'linear'
64
+
* 'hamming'
65
+
* 'lanczos' or 'antialias'
66
+
"""
67
+
ifisinstance(resampling_algorithm, int):
68
+
self.resampling_algorithm=resampling_algorithm
69
+
else:
70
+
raiseValueError(
71
+
"resampling_algorithm has to be an int, one of the values defined in RESAMPLING_ALGORITHMS or a Pillow resampling filter constant. Available algorithms: 'bicubic', 'nearest', 'box', 'bilinear', 'hamming', 'lanczos'."
72
+
)
73
+
45
74
defreset_points(self):
46
75
# Corresponding corners of image are fixed to these 3 points
0 commit comments