Skip to content

Commit

Permalink
Merge pull request #5 from ToraNova/master
Browse files Browse the repository at this point in the history
remove print statement from avatar crop and added a switch for uuid gen
  • Loading branch information
greyli authored Jan 20, 2021
2 parents 13eca90 + 7b332cc commit 58d5a06
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 58d5a06

Please sign in to comment.