Merge pull request #110 from yedpodtrzitko/yed/fix-thumbs-orientation

fix image thumbnails rotation
This commit is contained in:
Travis Abendshien
2024-05-01 03:00:46 -07:00
committed by GitHub

View File

@@ -10,7 +10,7 @@ import os
from pathlib import Path
import cv2
from PIL import Image, ImageChops, UnidentifiedImageError, ImageQt, ImageDraw, ImageFont, ImageEnhance
from PIL import Image, ImageChops, UnidentifiedImageError, ImageQt, ImageDraw, ImageFont, ImageEnhance, ImageOps
from PySide6.QtCore import QObject, Signal, QSize
from PySide6.QtGui import QPixmap
from src.core.ts_core import PLAINTEXT_TYPES, VIDEO_TYPES, IMAGE_TYPES
@@ -60,9 +60,6 @@ class ThumbRenderer(QObject):
ext_font = ImageFont.truetype(os.path.normpath(
f'{Path(__file__).parent.parent.parent.parent}/resources/qt/fonts/Oxanium-Bold.ttf'), math.floor(12*font_pixel_ratio))
def __init__(self):
QObject.__init__(self)
def render(self, timestamp: float, filepath, base_size: tuple[int, int], pixelRatio: float, isLoading=False):
"""Renders an entry/element thumbnail for the GUI."""
adj_size: int = 1
@@ -107,6 +104,8 @@ class ThumbRenderer(QObject):
if image.mode != 'RGB':
image = image.convert(mode='RGB')
image = ImageOps.exif_transpose(image)
# Videos =======================================================
elif extension in VIDEO_TYPES:
video = cv2.VideoCapture(filepath)
@@ -265,6 +264,8 @@ class ThumbRenderer(QObject):
image = new_bg
if image.mode != 'RGB':
image = image.convert(mode='RGB')
image = ImageOps.exif_transpose(image)
# Videos =======================================================
elif extension in VIDEO_TYPES: