Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove print statement from avatar crop and added a switch for uuid gen #5

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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