Skip to content

Commit 57bf2a5

Browse files
committed
continue renderer work
1 parent 22d1b70 commit 57bf2a5

7 files changed

Lines changed: 441 additions & 423 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ dependencies = [
2121
"mutagen~=1.47",
2222
"numpy~=2.2",
2323
"opencv_python~=4.11",
24-
"Pillow>=10.2,<12",
2524
"pillow-heif~=1.5.0",
2625
"pillow-jxl-plugin~=1.3",
26+
"Pillow>=10.2,<12",
2727
"py7zr~=1.1.3",
2828
"pydantic~=2.10",
2929
"pydub~=0.25",
30+
"Pygments~=2.21",
3031
"PySide6==6.11.2",
3132
"rarfile==4.2",
3233
"rawpy~=0.27",
34+
"requests~=2.31.0",
35+
"semver~=3.0.4",
3336
"Send2Trash>=1.8,<3",
3437
"SQLAlchemy~=2.0",
3538
"srctools~=2.6",
@@ -38,8 +41,6 @@ dependencies = [
3841
"typing_extensions~=4.13",
3942
"ujson~=5.10",
4043
"wcmatch==10.*",
41-
"requests~=2.31.0",
42-
"semver~=3.0.4",
4344
]
4445

4546
[project.gui-scripts]

src/tagstudio/core/media_types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def register(group: MediaTypeGroup) -> None:
417417
]
418418
+ midi.types,
419419
)
420+
MediaTypes.register(audio)
420421

421422
# RAW Images -----------------------------------------------------------------------------------
422423
raw_image = MediaTypeGroup(
@@ -608,6 +609,12 @@ def register(group: MediaTypeGroup) -> None:
608609
],
609610
[SEARCH, RENDER],
610611
),
612+
_Type(
613+
[
614+
".plist",
615+
],
616+
[SEARCH, RENDER],
617+
),
611618
_Type(".toml", [SEARCH, RENDER]),
612619
],
613620
)
@@ -936,7 +943,6 @@ class MediaCategories:
936943
".epub",
937944
".fb2",
938945
".ibook",
939-
".inf",
940946
".kfx",
941947
".lit",
942948
".mobi",

src/tagstudio/previews/effects.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from tagstudio.core.enums import Theme
2+
from tagstudio.qt.views.styles.palette import ColorType, UiColor, get_ui_color
3+
from PIL import ImageDraw, ImageFont, UnidentifiedImageError
4+
from PIL.Image import DecompressionBombError, Image, Resampling
5+
from PIL.Image import new as new_image
6+
from PIL.Image import open as open_image
7+
8+
9+
# TODO: Split out Qt color palette stuff from anything needed by the core.
10+
def apply_overlay_color(image: Image, color: UiColor, theme: Theme) -> Image:
11+
"""Apply a color overlay effect to an image based on its color channel data.
12+
13+
Red channel for foreground, green channel for outline, none for background.
14+
15+
Args:
16+
image (Image.Image): The image to apply an overlay to.
17+
color (UiColor): The name of the ColorType color to use.
18+
theme (Theme): A theme enum to determine the light/dark theme.
19+
"""
20+
bg_color: str = (
21+
get_ui_color(ColorType.DARK_ACCENT, color)
22+
if theme == Theme.DARK
23+
else get_ui_color(ColorType.PRIMARY, color)
24+
)
25+
fg_color: str = (
26+
get_ui_color(ColorType.PRIMARY, color)
27+
if theme == Theme.DARK
28+
else get_ui_color(ColorType.LIGHT_ACCENT, color)
29+
)
30+
ol_color: str = (
31+
get_ui_color(ColorType.BORDER, color)
32+
if theme == Theme.DARK
33+
else get_ui_color(ColorType.LIGHT_ACCENT, color)
34+
)
35+
36+
bg: Image = new_image(image.mode, image.size, color=bg_color)
37+
fg: Image = new_image(image.mode, image.size, color=fg_color)
38+
ol: Image = new_image(image.mode, image.size, color=ol_color)
39+
40+
bg.paste(fg, (0, 0), mask=image.getchannel(0))
41+
bg.paste(ol, (0, 0), mask=image.getchannel(1))
42+
43+
if image.mode == "RGBA":
44+
alpha_bg: Image = bg.copy()
45+
alpha_bg.convert("RGBA")
46+
alpha_bg.putalpha(0)
47+
alpha_bg.paste(bg, (0, 0), mask=image.getchannel(3))
48+
bg = alpha_bg
49+
50+
return bg

0 commit comments

Comments
 (0)