Skip to content

feat: add JXL thumbnail and animated APNG + WEBP support (port #344 and partially port #357) #549

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

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 13 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
chardet==5.2.0
ffmpeg-python==0.2.0
humanfriendly==10.0
mutagen==1.47.0
numpy==1.26.4
numpy==1.26.4
opencv_python>=4.8.0.74,<=4.9.0.80
pillow-heif==0.16.0
pillow-jxl-plugin==1.2.6
Pillow==10.3.0
PySide6==6.7.1
pydub==0.25.1
PySide6_Addons==6.7.1
PySide6_Essentials==6.7.1
typing_extensions>=3.10.0.0,<=4.11.0
ujson>=5.8.0,<=5.9.0
numpy==1.26.4
PySide6==6.7.1
rawpy==0.21.0
pillow-heif==0.16.0
chardet==5.2.0
structlog==24.4.0
SQLAlchemy==2.0.34
pydub==0.25.1
mutagen==1.47.0
numpy==1.26.4
ffmpeg-python==0.2.0
vtf2img==0.1.0
structlog==24.4.0
typing_extensions>=3.10.0.0,<=4.11.0
ujson>=5.8.0,<=5.9.0
vtf2img==0.1.0
1 change: 0 additions & 1 deletion tagstudio/src/core/media_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class MediaCategories:
".apng",
".gif",
".webp",
".jxl",
}
_IMAGE_RAW_SET: set[str] = {
".arw",
Expand Down
39 changes: 27 additions & 12 deletions tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (C) 2024 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio

import io
import os
import platform
import sys
Expand Down Expand Up @@ -601,19 +603,32 @@ def update_widgets(self) -> bool:
# TODO: Do this all somewhere else, this is just here temporarily.
ext: str = filepath.suffix.lower()
try:
if filepath.suffix.lower() in [".gif"]:
with open(filepath, mode="rb") as file:
if self.preview_gif.movie():
self.preview_gif.movie().stop()
self.gif_buffer.close()

ba = file.read()
self.gif_buffer.setData(ba)
movie = QMovie(self.gif_buffer, QByteArray())
self.preview_gif.setMovie(movie)
movie.start()
if MediaCategories.is_ext_in_category(
ext, MediaCategories.IMAGE_ANIMATED_TYPES, mime_fallback=True
):
if self.preview_gif.movie():
self.preview_gif.movie().stop()
self.gif_buffer.close()

image: Image.Image = Image.open(filepath)
anim_image: Image.Image = image
image_bytes_io: io.BytesIO = io.BytesIO()
anim_image.save(
image_bytes_io,
"GIF",
lossless=True,
save_all=True,
loop=0,
disposal=2,
)
image_bytes_io.seek(0)
ba: bytes = image_bytes_io.read()

self.gif_buffer.setData(ba)
movie = QMovie(self.gif_buffer, QByteArray())
self.preview_gif.setMovie(movie)
movie.start()

image = Image.open(str(filepath))
self.resizeEvent(
QResizeEvent(
QSize(image.width, image.height),
Expand Down
1 change: 1 addition & 0 deletions tagstudio/src/qt/widgets/thumb_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import cv2
import numpy as np
import pillow_jxl # noqa: F401
import rawpy
import structlog
from mutagen import MutagenError, flac, id3, mp4
Expand Down