Skip to content

Commit

Permalink
remove print statement from avatar crop, add switch for uuid filename…
Browse files Browse the repository at this point in the history
… generation
  • Loading branch information
ToraNova committed Jan 19, 2021
1 parent 13eca90 commit 7b332cc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions flask_avatars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def save_avatar(self, image):
image.save(os.path.join(path, filename))
return filename

def crop_avatar(self, filename, x, y, w, h):
def crop_avatar(self, filename, x, y, w, h, uuid_filename = True):
"""Crop avatar with given size, return a list of file name: [filename_s, filename_m, filename_l].
:param filename: The raw image's filename.
Expand All @@ -317,8 +317,6 @@ def crop_avatar(self, filename, x, y, w, h):
else:
path = os.path.join(current_app.config['AVATARS_SAVE_PATH'], filename)

print(path)

raw_img = Image.open(path)

base_width = current_app.config['AVATARS_CROP_BASE_WIDTH']
Expand All @@ -328,7 +326,8 @@ def crop_avatar(self, filename, x, y, w, h):

cropped_img = raw_img.crop((x, y, x + w, y + h))

filename = uuid4().hex
if uuid_filename:
filename = uuid4().hex

avatar_s = self.resize_avatar(cropped_img, base_width=sizes[0])
avatar_m = self.resize_avatar(cropped_img, base_width=sizes[1])
Expand Down

0 comments on commit 7b332cc

Please sign in to comment.