Skip to content

Commit

Permalink
refactor: skip converting .webp
Browse files Browse the repository at this point in the history
Skips converting .webp to .avif to preserve .webp animation and because .webps are a good file size already
  • Loading branch information
johnfraney committed Apr 27, 2024
1 parent 488cf83 commit 2b45eb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion blurry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ async def process_non_markdown_file(filepath: Path):
if mimetype in [
mimetypes.types_map[".jpg"],
mimetypes.types_map[".png"],
mimetypes.common_types[".webp"],
]:
await generate_images_for_srcset(filepath)

Expand Down
4 changes: 3 additions & 1 deletion blurry/markdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def image(self, text, url, title=None) -> str:
with Image(filename=str(absolute_path)) as img:
image_width = img.width
image_height = img.height
image_is_animated = img.animation
# The .animated property doesn't always detect animated .webp images
# and .webp is optimized enough not to benefit much from .avif
image_is_animated = img.animation or extension.lower() == "webp"
attributes["width"] = image_width
attributes["height"] = image_height

Expand Down

0 comments on commit 2b45eb1

Please sign in to comment.