Author: physik
Description:
Version: unspecified
Severity: normal
Author: physik
Description:
Version: unspecified
Severity: normal
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Mathoid: enable PNG generation | operations/puppet | production | +6 -6 | |
WIP: png support for mathoid | mediawiki/services/mathoid | master | +3 K -2 |
Currently requests for PNG fall-back images like https://en.wikipedia.org/w/index.php?title=Special:MathShowImage&hash=3636bb81514ee0ab8cc120633e1ebc97&mode=0 return internal server errors.
It also seems that we currently load those even if SVG or MathML is supported, which is not ideal. Should we just remove the reference to them for now in the math extension until they are actually supported?
Change 165658 had a related patch set uploaded by GWicke:
Bug 69702: Remove PNG image fallback image references
Change 165658 had a related patch set uploaded by Krinkle:
Remove PNG image fallback image references
Just FYI, if Apache Batik is a problem and you find a better solution, we're open to changing MathJax-node.
The proposed WIP change does the job. It returns the an additional json key value pair like: "png":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAEZ0FNQQAAsY58+1GTAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAX9JREFUeNqt1M0rRFEYx3HDJCLJy4IZjNfISyGkZGOQUMRCNpZk42XJCiv5A6xIKcXKZkqiZGFSUixIsUGEstBMROR76nd1ujty6tM5c89zn+5zn3PHE/P7MYt8pOAVA/am9w8Ja1CGApy5N2P/kLAL+1pf/0fCIiRqffMfCRuQjTdMujfjXL9TMY1xNKmkCRziXTGmCT3a82EMzdjCl52wUBfbcYlGDKMFGQgpbgh1iIcftwiiHyteq9ubCKANYa0PtHekOJMgTetjdCOCbbRiKtY6WxU4VbIYPakp8w7rutaHdEQxo2RmfGiudBIOal6zXkEp8nBv3WiaUa1re1ZsluZ3J2GOblqygvyaw66mJegd23HGJ5a91vG501FwRkDzIlbxYJ2/RytuFJk4x67zhC+m5a6Om8/rSd0MqjER13FL1hGKqkE/G6YBJahFLxbgkVz9EYzgAp36jssxp9fVgRM7YUgl+lS+KXMeVUgypWAHz9hAPYpxpYc5d0r7Blj0TcypBbJRAAAAAElFTkSuQmCC"
the downside is that it requires java to be installed
Change 178645 had a related patch set uploaded (by Physikerwelt):
WIP: png support for mathoid
The alternative to the change https://gerrit.wikimedia.org/r/178645 is to create a different service that takes care of the SVG to PNG conversion.
If this functionality was build into MediaWiki core an API could look like
wfSvg2Png($input,$output) returns boolean
the $input can either be a url or a string and the return value indicates if the conversion was successful or not.
In any case $output should be a binary PNG image that will be printed unmodified to the page using echo.
If the conversion fails a default image should be returned that indicates there was a problem. The return value is in that cased used to reduce the cache livetime for the failed image
Peter, via mail:
AFAIK, there is no "pure" JS svg2png converter. Some options are
rsvg is what we are using in production so far. Our opsens generally dislike dealing with Java stuff if avoidable, so I think rsvg would be an easier sell. I would also expect rsvg to perform better. The downside is that it does not support embedded HTML, which the phantomjs-based solution might. I recently found out about that when I used an online diagramming tool that emitted such SVGs.
Setting up a small service that takes an URL/path to an SVG and returns the PNG rendering of that SVG should not be too hard, and can be used as a fall-back mechanism for different use cases. We don't want to accept arbitrary URLs, but that should be relatively easy to lock down with a whitelist regexp. For now, we could expose this as another end point from mathoid for ease of deployment. We should keep the code separate though, so that it is easy to move it to a separate service later.
I had a look at the last weekend at libRSVG with MathJax-node https://github.com/wikimedia/MathJax-node/tree/librsvg
... not very successfull though.
I woul very much prefer if RESTBase would be able to convert SVG to PNG. For this problem it is more or less irrelevant that the content of the images is Math. (OK... maybe there are some strage utf-8 chars... but this a minor detail.)
What do you think?
I wonder how are all the other svg images rendered? Can't we just use this service?
I'm referring to the service behind https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/10042px-SVG_logo.svg.png. If it could read the SVG from mathoid or restbase we were done
@cscott: You mentioned that you could potenially implement a rsvg package for node, which would not require temporary files. Did you invest this possibility further?
We have
https://github.com/wikimedia/MathJax-node/pull/16
now, an alternative could be T78579.
Change 276734 had a related patch set uploaded (by Mobrovac):
Mathoid: enable PNG generation
The PR has been merged and deployed: RESTBase and Mathoid now support and serve PNG renders as well. Resolving.