-
-
Notifications
You must be signed in to change notification settings - Fork 19
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 conversion (e.g. to convert favicon) and confirm probing is OK #113
Comments
Browsers support SVG 1.1: SVG 2 does not yet seem to be supported by browsers: Never easy to align with "all" browsers... but if attainable... Awesome! |
Would nice indeed, but maybe we can wait the first use case to do it. |
It is quite common with zimit website to have a favicon in SVG format. This fails to be processed currently. |
We should go to have a smooth conversion to the expected ZIM Illustration PNG format. For the rest, like written by @holta, we have meanwhile a broad SVG format and we should not force a bitmap conversion. |
It looks like CairoSVG is the most popular lib to use. But its support is very questionable/complex: Kozea/CairoSVG#298 ; main supporters even dropped it from their software due to limitations / too complex support: https://www.courtbouillon.org/blog/00009-weasyprint-53-what-s-new/#svg-rendering. An alternative could be svglib but it also needs Reportlab toolkit, support seems limited, CI is failing, Python 3.11 and 3.12 are not even mentioned. Another alternative could be librvsg and its Python bindings. Advantage is that librsvg is a Gnome project and seems to still be supported. But the Python bindings clearly lacks documentation, I struggle to find how to configure it properly. Final alternative is an external tool like Inkscape or ImageMagick. Both are well supported and it is their "core purpose". I would tend to prefer ImageMagick for its versatility + the fact that it is a pure command-line tool. Inkscape has a CLI interface but it looks like it does not provide CLI-only executables, you have to install the GUI and all its dependencies. So my favorite was to consider relying on ImageMagick for SVG to PNG conversion. However, tests with real svgs on the test set have shown to be a disaster with ImageMagick (python failed mostly completely, gfonts is extremely blurry, other are blurry as well). I tried the second contender on my list (cairosvg) and it worked very smoothly. Command used in ImageMagick (might be the problem; density has been added to try enhance the result but did not changed anything):
Command used in cairo:
I also confirmed that cairosvg is not distorting the image if original image is not squared (should probably never happen, but who knows ...). Finally, becoming a sponsor of CourtBouillon team with is supporting cairosvg but also the tinycss2 we are already using is probably something to consider I will create a PR with cairosvg. |
My experience (mostly with Mediawiki) is with librsvg. It is already a few years old, but work fine. |
Just changed the title to confirm that this issue will focus on conversion (todo) + probing (probably already working with PIL). SVG optimization is already tracked in #80 and will need a different tooling. |
Our image functions all assume bitmap input or output. Should we support vector formats as well (SVG's the only open and widespread one I think)? If so, should it be using different API or should this be handled transparently?
The text was updated successfully, but these errors were encountered: