|
47 | 47 |
|
48 | 48 | try: |
49 | 49 | from PIL import Image, ImageOps |
| 50 | + |
| 51 | + LANCZOS = Image.LANCZOS if hasattr(Image, "LANCZOS") else Image.ANTIALIAS |
50 | 52 | except ImportError: |
51 | 53 | Image = None |
52 | 54 | ImageOps = None |
@@ -1946,23 +1948,19 @@ def put(self, file_obj, **kwargs): |
1946 | 1948 | size = field.size |
1947 | 1949 |
|
1948 | 1950 | if size["force"]: |
1949 | | - img = ImageOps.fit( |
1950 | | - img, (size["width"], size["height"]), Image.ANTIALIAS |
1951 | | - ) |
| 1951 | + img = ImageOps.fit(img, (size["width"], size["height"]), LANCZOS) |
1952 | 1952 | else: |
1953 | | - img.thumbnail((size["width"], size["height"]), Image.ANTIALIAS) |
| 1953 | + img.thumbnail((size["width"], size["height"]), LANCZOS) |
1954 | 1954 |
|
1955 | 1955 | thumbnail = None |
1956 | 1956 | if field.thumbnail_size: |
1957 | 1957 | size = field.thumbnail_size |
1958 | 1958 |
|
1959 | 1959 | if size["force"]: |
1960 | | - thumbnail = ImageOps.fit( |
1961 | | - img, (size["width"], size["height"]), Image.ANTIALIAS |
1962 | | - ) |
| 1960 | + thumbnail = ImageOps.fit(img, (size["width"], size["height"]), LANCZOS) |
1963 | 1961 | else: |
1964 | 1962 | thumbnail = img.copy() |
1965 | | - thumbnail.thumbnail((size["width"], size["height"]), Image.ANTIALIAS) |
| 1963 | + thumbnail.thumbnail((size["width"], size["height"]), LANCZOS) |
1966 | 1964 |
|
1967 | 1965 | if thumbnail: |
1968 | 1966 | thumb_id = self._put_thumbnail(thumbnail, img_format, progressive) |
|
0 commit comments