fix image thumbnails rotation

This commit is contained in:
yedpodtrzitko 2024-05-01 17:15:33 +08:00
parent 67c18e9a25
commit 8604a7f08f

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)