Skip to content

Commit

Permalink
update deprecated PIL statement (#5570)
Browse files Browse the repository at this point in the history
  • Loading branch information
likesclever committed Aug 3, 2023
1 parent 9e8e4d6 commit cbe0817
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion seahub/avatar/settings.py
Expand Up @@ -22,7 +22,7 @@

### Common settings ###
AVATAR_FILE_STORAGE = getattr(settings, 'AVATAR_FILE_STORAGE', '')
AVATAR_RESIZE_METHOD = getattr(settings, 'AVATAR_RESIZE_METHOD', Image.ANTIALIAS)
AVATAR_RESIZE_METHOD = getattr(settings, 'AVATAR_RESIZE_METHOD', Image.Resampling.LANCZOS)
AVATAR_GRAVATAR_BACKUP = getattr(settings, 'AVATAR_GRAVATAR_BACKUP', True)
AVATAR_GRAVATAR_DEFAULT = getattr(settings, 'AVATAR_GRAVATAR_DEFAULT', None)
AVATAR_MAX_AVATARS_PER_USER = getattr(settings, 'AVATAR_MAX_AVATARS_PER_USER', 42)
Expand Down
10 changes: 5 additions & 5 deletions seahub/thumbnail/utils.py
Expand Up @@ -54,22 +54,22 @@ def get_rotated_image(image):

if orientation == 2:
# Vertical image
image = image.transpose(Image.FLIP_LEFT_RIGHT)
image = image.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
elif orientation == 3:
# Rotation 180
image = image.rotate(180)
elif orientation == 4:
image = image.rotate(180).transpose(Image.FLIP_LEFT_RIGHT)
image = image.rotate(180).transpose(Image.Transpose.FLIP_LEFT_RIGHT)
# Horizontal image
elif orientation == 5:
# Horizontal image + Rotation 90 CCW
image = image.rotate(-90, expand=True).transpose(Image.FLIP_LEFT_RIGHT)
image = image.rotate(-90, expand=True).transpose(Image.Transpose.FLIP_LEFT_RIGHT)
elif orientation == 6:
# Rotation 270
image = image.rotate(-90, expand=True)
elif orientation == 7:
# Horizontal image + Rotation 270
image = image.rotate(90, expand=True).transpose(Image.FLIP_LEFT_RIGHT)
image = image.rotate(90, expand=True).transpose(Image.Transpose.FLIP_LEFT_RIGHT)
elif orientation == 8:
# Rotation 90
image = image.rotate(90, expand=True)
Expand Down Expand Up @@ -230,7 +230,7 @@ def _create_thumbnail_common(fp, thumbnail_file, size):
image = image.convert("RGB")

image = get_rotated_image(image)
image.thumbnail((size, size), Image.ANTIALIAS)
image.thumbnail((size, size), Image.Resampling.LANCZOS)
image.save(thumbnail_file, THUMBNAIL_EXTENSION)
return (True, 200)

Expand Down

0 comments on commit cbe0817

Please sign in to comment.