mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
adding default quality param to create_thumbnail
Signed-off-by: Jannis Leidel <jannis@leidel.info>
This commit is contained in:
parent
0307dc2a79
commit
233422eefd
1 changed files with 2 additions and 2 deletions
|
|
@ -82,7 +82,7 @@ class Avatar(models.Model):
|
|||
def thumbnail_exists(self, size):
|
||||
return self.avatar.storage.exists(self.avatar_name(size))
|
||||
|
||||
def create_thumbnail(self, size):
|
||||
def create_thumbnail(self, size, quality=95):
|
||||
try:
|
||||
orig = self.avatar.storage.open(self.avatar.name, 'rb').read()
|
||||
image = Image.open(StringIO(orig))
|
||||
|
|
@ -100,7 +100,7 @@ class Avatar(models.Model):
|
|||
if image.mode != "RGB":
|
||||
image = image.convert("RGB")
|
||||
thumb = StringIO()
|
||||
image.save(thumb, AVATAR_THUMB_FORMAT)
|
||||
image.save(thumb, AVATAR_THUMB_FORMAT, quality=quality)
|
||||
thumb_file = ContentFile(thumb.getvalue())
|
||||
else:
|
||||
thumb_file = ContentFile(orig)
|
||||
|
|
|
|||
Loading…
Reference in a new issue