From a99d8c654d5d75a9b21664422b3d15e19609fa9f Mon Sep 17 00:00:00 2001 From: mungai-njoroge Date: Sat, 13 Apr 2024 20:25:43 +0300 Subject: [PATCH] bump large thumbnails to 512 px + stop extracting original thumbnails --- app/api/imgserver.py | 20 ++++++++++---------- app/lib/taglib.py | 2 -- app/migrations/v1_4_9/__init__.py | 8 ++++++++ app/settings.py | 6 +----- app/setup/files.py | 2 -- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/api/imgserver.py b/app/api/imgserver.py index 45e3d34d..680abba1 100644 --- a/app/api/imgserver.py +++ b/app/api/imgserver.py @@ -29,18 +29,18 @@ class ImagePath(BaseModel): ) -@api.get("/t/o/") -def send_original_thumbnail(path: ImagePath): - """ - Get original thumbnail - """ - folder = Paths.get_original_thumb_path() - fpath = Path(folder) / path.imgpath +# @api.get("/t/o/") +# def send_original_thumbnail(path: ImagePath): +# """ +# Get original thumbnail +# """ +# folder = Paths.get_original_thumb_path() +# fpath = Path(folder) / path.imgpath - if fpath.exists(): - return send_from_directory(folder, path.imgpath) +# if fpath.exists(): +# return send_from_directory(folder, path.imgpath) - return send_fallback_img() +# return send_fallback_img() @api.get("/t/") diff --git a/app/lib/taglib.py b/app/lib/taglib.py index 63fd4d7e..2a523144 100644 --- a/app/lib/taglib.py +++ b/app/lib/taglib.py @@ -31,7 +31,6 @@ def extract_thumb(filepath: str, webp_path: str, overwrite=False) -> bool: Extracts the thumbnail from an audio file. Returns the path to the thumbnail. """ - original_img_path = os.path.join(Paths.get_original_thumb_path(), webp_path) lg_img_path = os.path.join(Paths.get_lg_thumb_path(), webp_path) sm_img_path = os.path.join(Paths.get_sm_thumb_path(), webp_path) @@ -42,7 +41,6 @@ def extract_thumb(filepath: str, webp_path: str, overwrite=False) -> bool: width, height = img.size ratio = width / height - img.save(original_img_path, "webp") img.resize((tsize, int(tsize / ratio)), Image.ANTIALIAS).save( lg_img_path, "webp" ) diff --git a/app/migrations/v1_4_9/__init__.py b/app/migrations/v1_4_9/__init__.py index a925db34..864cc303 100644 --- a/app/migrations/v1_4_9/__init__.py +++ b/app/migrations/v1_4_9/__init__.py @@ -39,3 +39,11 @@ class MoveHashesToSha1(Migration): # INFO: Apparentlly, every single table is affected by this migration. # NOTE: Use generators to avoid memory issues. + + +class DeleteOriginalThumbnails(Migration): + """ + Original thumbnails are too large and are not needed. + """ + # TODO: Implement this migration + pass diff --git a/app/settings.py b/app/settings.py index 77d3aecc..b91f28fb 100644 --- a/app/settings.py +++ b/app/settings.py @@ -73,10 +73,6 @@ class Paths: def get_lg_thumb_path(cls): return join(cls.get_thumbs_path(), "large") - @classmethod - def get_original_thumb_path(cls): - return join(cls.get_thumbs_path(), "original") - @classmethod def get_assets_path(cls): return join(Paths.get_app_dir(), "assets") @@ -92,7 +88,7 @@ class Paths: # defaults class Defaults: - THUMB_SIZE = 500 + THUMB_SIZE = 512 SM_THUMB_SIZE = 128 SM_ARTIST_IMG_SIZE = 128 """ diff --git a/app/setup/files.py b/app/setup/files.py index 96861217..46f6a001 100644 --- a/app/setup/files.py +++ b/app/setup/files.py @@ -54,7 +54,6 @@ def create_config_dir() -> None: thumb_path = os.path.join("images", "thumbnails") small_thumb_path = os.path.join(thumb_path, "small") large_thumb_path = os.path.join(thumb_path, "large") - original_thumb_path = os.path.join(thumb_path, "original") artist_img_path = os.path.join("images", "artists") small_artist_img_path = os.path.join(artist_img_path, "small") @@ -70,7 +69,6 @@ def create_config_dir() -> None: thumb_path, small_thumb_path, large_thumb_path, - original_thumb_path, artist_img_path, small_artist_img_path, large_artist_img_path,