mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-11 10:23:12 -05:00
bug/bug-fixes (#424)
* fix image write/caching * Caddyfile Caching header * more aggressive caching Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -36,7 +36,7 @@ def write_image(recipe_slug: str, file_data: bytes, extension: str) -> Path:
|
||||
shutil.copyfileobj(file_data, f)
|
||||
|
||||
print(image_path)
|
||||
minify.minify_image(image_path)
|
||||
minify.minify_image(image_path, force=True)
|
||||
|
||||
return image_path
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def get_image_sizes(org_img: Path, min_img: Path, tiny_img: Path) -> ImageSizes:
|
||||
return ImageSizes(org=sizeof_fmt(org_img), min=sizeof_fmt(min_img), tiny=sizeof_fmt(tiny_img))
|
||||
|
||||
|
||||
def minify_image(image_file: Path) -> ImageSizes:
|
||||
def minify_image(image_file: Path, force=False) -> ImageSizes:
|
||||
"""Minifies an image in it's original file format. Quality is lost
|
||||
|
||||
Args:
|
||||
@@ -39,7 +39,7 @@ def minify_image(image_file: Path) -> ImageSizes:
|
||||
min_dest = image_file.parent.joinpath("min-original.webp")
|
||||
tiny_dest = image_file.parent.joinpath("tiny-original.webp")
|
||||
|
||||
if min_dest.exists() and tiny_dest.exists() and org_dest.exists():
|
||||
if min_dest.exists() and tiny_dest.exists() and org_dest.exists() and not force:
|
||||
return
|
||||
try:
|
||||
img = Image.open(image_file)
|
||||
@@ -56,7 +56,8 @@ def minify_image(image_file: Path) -> ImageSizes:
|
||||
|
||||
cleanup_images = True
|
||||
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
shutil.copy(image_file, min_dest)
|
||||
shutil.copy(image_file, tiny_dest)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user