Skip to content

Social card previews break when SVG images present #96

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

Closed
kovidgoyal opened this issue Feb 7, 2023 · 3 comments · Fixed by #97
Closed

Social card previews break when SVG images present #96

kovidgoyal opened this issue Feb 7, 2023 · 3 comments · Fixed by #97

Comments

@kovidgoyal
Copy link

Here is the traceback

Traceback (most recent call last):
17
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinx/events.py", line 96, in emit
18
    results.append(listener.handler(self.app, *args))
19
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinxext/opengraph/__init__.py", line 254, in html_page_context
20
    context["metatags"] += get_tags(app, context, doctree, app.config)
21
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinxext/opengraph/__init__.py", line 165, in get_tags
22
    image_path = create_social_card(
23
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinxext/opengraph/socialcards.py", line 105, in create_social_card
24
    plt_objects = render_social_card(
25
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinxext/opengraph/socialcards.py", line 140, in render_social_card
26
    ) = create_social_card_objects(**kwargs_fig)
27
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sphinxext/opengraph/socialcards.py", line 274, in create_social_card_objects
28
    img = mpimg.imread(image)
29
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/matplotlib/image.py", line 1541, in imread
30
    with img_open(fname) as image:
31
  File "/Users/runner/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/PIL/Image.py", line 3283, in open
32
    raise UnidentifiedImageError(msg)
33
PIL.UnidentifiedImageError: cannot identify image file '/Users/runner/work/kitty/kitty/logo/kitty.svg'
34
@hugovk
Copy link
Contributor

hugovk commented Feb 7, 2023

Ping @choldgraf

@choldgraf
Copy link
Contributor

ah I guess there should be a check to disable this functionality if the logo is an SVG an no custom logo is given by the user?

Otherwise we could try to find a way to add SVG plotting to Matplotlib, but I don't know how to do that.

wmfgerrit pushed a commit to wikimedia/pywikibot that referenced this issue Feb 7, 2023
https: //github.com/sphinx-doc/sphinxext-opengraph/issues/96

Change-Id: If292800c47db69726709a7981812f1c0bd75b29a
@TheTripleV
Copy link
Collaborator

Note for the future, we do have a wrapper around a bunch of system svg -> png converters in another sphinx extension (https://github.com/wpilibsuite/sphinxext-photofinish/blob/main/sphinxext/photofinish/svgtopng.py#L73).
I don't know if it makes sense to split that file off into it's own library but we could just duplicate it in this repo.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants