Skip to content
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

Add support for SVG->PNG conversion #4

Merged
merged 1 commit into from Jan 7, 2021
Merged

Add support for SVG->PNG conversion #4

merged 1 commit into from Jan 7, 2021

Conversation

bwidawsk
Copy link
Contributor

@bwidawsk bwidawsk commented Jan 2, 2021

SVG is fraught with differences across web browsers. As such, thumbnail generation would benefit from converting to a more accepted format such as png. It is nice however to be able to link to the source SVG file in case people want to open in a different program and benefit from infinite scaling. Inkscape is the main driver for conversion as it seems to be the best currently.

This patch could use some work:

  1. Currently won't work on Windows.
  2. Inkscape 1.0+ is supported (older versions had different commandline invocation)
  3. Could benefit quality knobs for the resulting png
  4. High level config option to pick resulting output format (png, jpg, whatever)

I have no intention to fix any of those because they don't matter to me. I thought perhaps someone else could benefit from this and so I am submitting the PR as is.

My use of this is with shortcodes plugin. For example to have the "medium" thumbnail be displayed, but have it link to the svg can be done with the following
svg-image = '<div class="align{{ align }}">{% if link %}<a href="{{ link }}"{% if not link.startswith("http") %} data-lightbox="gallery"{% endif %}>{% endif %}{% set name,ext = image.split('.') %} <img src="{{ name+'-medium.png'}}">{% if link %}</a>{% endif %}{% if caption %}<span class="caption">{{ caption }}</span>{% endif %}</div>'

This is currently Linux only, and Inkscape 1.0+
@skorokithakis
Copy link
Owner

This looks good, thanks! I'll test it shortly and merge if everything works well.

@skorokithakis skorokithakis merged commit 6a59687 into skorokithakis:master Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants