Skip to content

Commit 174262b

Browse files
feat(thumbs): render .ai thumbnails (#1453)
1 parent 27d7617 commit 174262b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/tagstudio/core/media_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class MediaCategories:
105105
# These sets are used either individually or together to form the final sets
106106
# for the MediaCategory(s).
107107
# These sets may be combined and are NOT 1:1 with the final categories.
108+
_ADOBE_ILLUSTRATOR_SET: set[str] = {".ai"}
108109
_ADOBE_PHOTOSHOP_SET: set[str] = {
109110
".pdd",
110111
".psb",
@@ -580,7 +581,7 @@ class MediaCategories:
580581
)
581582
PDF_TYPES = MediaCategory(
582583
media_type=MediaType.PDF,
583-
extensions=_PDF_SET,
584+
extensions=_PDF_SET | _ADOBE_ILLUSTRATOR_SET,
584585
is_iana=False,
585586
name="pdf",
586587
)

src/tagstudio/qt/previews/renderer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,11 +1295,12 @@ def _model_stl_thumb(filepath: Path, size: int) -> Image.Image | None: # pyrigh
12951295
return im
12961296

12971297
@staticmethod
1298-
def _pdf_thumb(filepath: Path, size: int) -> Image.Image | None:
1299-
"""Render a thumbnail for a PDF file.
1298+
def _pdf_thumb(filepath: Path, size: int, ext: str) -> Image.Image | None:
1299+
"""Render a thumbnail for a PDF or Adobe Illustator file.
13001300
13011301
filepath (Path): The path of the file.
13021302
size (int): The size of the icon.
1303+
ext (str): The file extension.
13031304
"""
13041305
im: Image.Image | None = None
13051306

@@ -1321,7 +1322,7 @@ def _pdf_thumb(filepath: Path, size: int) -> Image.Image | None:
13211322
else:
13221323
page_size *= size / page_size.width()
13231324
# Enlarge image for anti-aliasing
1324-
scale_factor = 2.5
1325+
scale_factor = 2.5 if ext in {".pdf"} else 1
13251326
page_size *= scale_factor
13261327
# Render image with no anti-aliasing for speed
13271328
render_options: QPdfDocumentRenderOptions = QPdfDocumentRenderOptions()
@@ -1910,7 +1911,7 @@ def _render(
19101911
elif MediaCategories.is_ext_in_category(
19111912
ext, MediaCategories.PDF_TYPES, mime_fallback=True
19121913
):
1913-
image = self._pdf_thumb(_filepath, adj_size)
1914+
image = self._pdf_thumb(_filepath, adj_size, ext)
19141915
# Archives =====================================================
19151916
elif MediaCategories.is_ext_in_category(ext, MediaCategories.ARCHIVE_TYPES):
19161917
image = self._archive_thumb(_filepath, ext)

0 commit comments

Comments
 (0)