Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Preserve orientation when converting to .webp #4803

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mealie/pkgs/img/minify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from logging import Logger
from pathlib import Path

from PIL import Image
from PIL import Image, ImageOps
from pillow_heif import register_avif_opener, register_heif_opener

register_heif_opener()
Expand Down Expand Up @@ -80,6 +80,7 @@ def _convert_image(
"""

img = Image.open(image_file)
img = ImageOps.exif_transpose(img)
if img.mode not in image_format.modes:
img = img.convert(image_format.modes[0])

Expand Down Expand Up @@ -142,6 +143,7 @@ def minify(self, image_file: Path, force=True):
self._logger.info(f"{image_file.name} already minified")
else:
img = Image.open(image_file)
img = ImageOps.exif_transpose(img)
tiny_image = PillowMinifier.crop_center(img)
tiny_image.save(tiny_dest, WEBP.format, quality=70)
self._logger.info("Tiny image saved")
Expand Down
Loading