bump large thumbnails to 512 px

+ stop extracting original thumbnails
This commit is contained in:
mungai-njoroge
2024-04-13 20:25:43 +03:00
parent cdfa546978
commit a99d8c654d
5 changed files with 19 additions and 19 deletions
+10 -10
View File
@@ -29,18 +29,18 @@ class ImagePath(BaseModel):
) )
@api.get("/t/o/<imgpath>") # @api.get("/t/o/<imgpath>")
def send_original_thumbnail(path: ImagePath): # def send_original_thumbnail(path: ImagePath):
""" # """
Get original thumbnail # Get original thumbnail
""" # """
folder = Paths.get_original_thumb_path() # folder = Paths.get_original_thumb_path()
fpath = Path(folder) / path.imgpath # fpath = Path(folder) / path.imgpath
if fpath.exists(): # if fpath.exists():
return send_from_directory(folder, path.imgpath) # return send_from_directory(folder, path.imgpath)
return send_fallback_img() # return send_fallback_img()
@api.get("/t/<imgpath>") @api.get("/t/<imgpath>")
-2
View File
@@ -31,7 +31,6 @@ def extract_thumb(filepath: str, webp_path: str, overwrite=False) -> bool:
Extracts the thumbnail from an audio file. Extracts the thumbnail from an audio file.
Returns the path to the thumbnail. 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) 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) 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 width, height = img.size
ratio = width / height ratio = width / height
img.save(original_img_path, "webp")
img.resize((tsize, int(tsize / ratio)), Image.ANTIALIAS).save( img.resize((tsize, int(tsize / ratio)), Image.ANTIALIAS).save(
lg_img_path, "webp" lg_img_path, "webp"
) )
+8
View File
@@ -39,3 +39,11 @@ class MoveHashesToSha1(Migration):
# INFO: Apparentlly, every single table is affected by this migration. # INFO: Apparentlly, every single table is affected by this migration.
# NOTE: Use generators to avoid memory issues. # NOTE: Use generators to avoid memory issues.
class DeleteOriginalThumbnails(Migration):
"""
Original thumbnails are too large and are not needed.
"""
# TODO: Implement this migration
pass
+1 -5
View File
@@ -73,10 +73,6 @@ class Paths:
def get_lg_thumb_path(cls): def get_lg_thumb_path(cls):
return join(cls.get_thumbs_path(), "large") return join(cls.get_thumbs_path(), "large")
@classmethod
def get_original_thumb_path(cls):
return join(cls.get_thumbs_path(), "original")
@classmethod @classmethod
def get_assets_path(cls): def get_assets_path(cls):
return join(Paths.get_app_dir(), "assets") return join(Paths.get_app_dir(), "assets")
@@ -92,7 +88,7 @@ class Paths:
# defaults # defaults
class Defaults: class Defaults:
THUMB_SIZE = 500 THUMB_SIZE = 512
SM_THUMB_SIZE = 128 SM_THUMB_SIZE = 128
SM_ARTIST_IMG_SIZE = 128 SM_ARTIST_IMG_SIZE = 128
""" """
-2
View File
@@ -54,7 +54,6 @@ def create_config_dir() -> None:
thumb_path = os.path.join("images", "thumbnails") thumb_path = os.path.join("images", "thumbnails")
small_thumb_path = os.path.join(thumb_path, "small") small_thumb_path = os.path.join(thumb_path, "small")
large_thumb_path = os.path.join(thumb_path, "large") 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") artist_img_path = os.path.join("images", "artists")
small_artist_img_path = os.path.join(artist_img_path, "small") small_artist_img_path = os.path.join(artist_img_path, "small")
@@ -70,7 +69,6 @@ def create_config_dir() -> None:
thumb_path, thumb_path,
small_thumb_path, small_thumb_path,
large_thumb_path, large_thumb_path,
original_thumb_path,
artist_img_path, artist_img_path,
small_artist_img_path, small_artist_img_path,
large_artist_img_path, large_artist_img_path,