Account for EXIF data during hashing/searching
PIL provides built-in support for transposing images based on EXIF Orientation. This change adds that call.
This commit is contained in:
parent
6e2a3eaf92
commit
e7ab2fe99f
1 changed files with 2 additions and 2 deletions
|
@ -7,7 +7,7 @@ from typing import Any, Callable, List, Optional, Set, Tuple
|
|||
import HeifImagePlugin
|
||||
import numpy as np
|
||||
import pillow_avif
|
||||
from PIL import Image
|
||||
from PIL import Image, ImageOps
|
||||
|
||||
from szurubooru import config, errors
|
||||
|
||||
|
@ -40,7 +40,7 @@ NpMatrix = np.ndarray
|
|||
|
||||
def _preprocess_image(content: bytes) -> NpMatrix:
|
||||
try:
|
||||
img = Image.open(BytesIO(content))
|
||||
img = ImageOps.exif_transpose(Image.open(BytesIO(content)))
|
||||
return np.asarray(img.convert("L"), dtype=np.uint8)
|
||||
except (IOError, ValueError):
|
||||
raise errors.ProcessingError(
|
||||
|
|
Loading…
Reference in a new issue