Skip to content

Commit

Permalink
fix: Preserve orientation when converting to .webp (#4803)
Browse files Browse the repository at this point in the history
Co-authored-by: Hayden <[email protected]>
  • Loading branch information
ConduciveMocha and hay-kot authored Jan 14, 2025
1 parent d7f460b commit aed93ce
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit aed93ce

Please sign in to comment.