Skip to content

Commit

Permalink
feat(app):
Browse files Browse the repository at this point in the history
- fix bug
  • Loading branch information
MorvanZhou committed Jul 26, 2024
1 parent d4240c6 commit 89bdad9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/retk/core/files/saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
from retk.models.client import client
from retk.models.tps import UserFile

RESIZE_IMAGE_TYPE = {".png", ".jpg", ".jpeg"}


@dataclass
class File:
data: BinaryIO
filename: str
ext: str = ""

def __post_init__(self):
self.data.seek(0)
Expand All @@ -39,8 +42,10 @@ def __post_init__(self):
self._reset_size()

def image_resize(self, resize_threshold: int):
if self.ext == ".gif" or self.type != FileTypesEnum.IMAGE:
if self.type != FileTypesEnum.IMAGE or self.ext not in RESIZE_IMAGE_TYPE:
return
if self.ext.lower() == ".jpg":
self.ext = ".jpeg"
if self.size > resize_threshold:
# reduce image size
out = io.BytesIO()
Expand Down

0 comments on commit 89bdad9

Please sign in to comment.