# Description

Author: physik

Description:

Version: unspecified
Severity: normal

# Related ObjectsSearch...

ResolvedNone
ResolvedPhysikerwelt
OpenNone
InvalidNone
OpenNone
OpenNone
OpenNone
OpenNone
OpenNone
ResolvedPhysikerwelt
ResolvedPhysikerwelt
OpenNone
DeclinedNone
ResolvedPhysikerwelt
OpenNone
ResolvedDebenben
ResolvedTheDJ
DeclinedPhysikerwelt
DuplicateNone
DuplicateNone
Resolvedmobrovac
ResolvedPhysikerwelt
ResolvedNone
Resolvedmobrovac
DeclinedPhysikerwelt
DeclinedPhysikerwelt

### Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:40 AM
bzimport set Reference to bz69702.
bzimport added a subscriber: Unknown Object (MLST).

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?

Bug 69702: Remove PNG image fallback image references

https://gerrit.wikimedia.org/r/165658

Remove PNG image fallback image references

https://gerrit.wikimedia.org/r/165658

Change 165658 merged by jenkins-bot:
Remove PNG image fallback image references

https://gerrit.wikimedia.org/r/165658

Pkra added a comment.Oct 24 2014, 2:51 PM

Just FYI, if Apache Batik is a problem and you find a better solution, we're open to changing MathJax-node.

TTO added a comment.Nov 12 2014, 4:03 AM

Patch was merged.

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

WIP: png support for mathoid

https://gerrit.wikimedia.org/r/178645

Patch-For-Review

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

Physikerwelt set Security to None.Dec 9 2014, 11:01 PM

Peter, via mail:

AFAIK, there is no "pure" JS svg2png converter. Some options are

• svg2png, popular, phantomjs-based, maintained by one of the jsdom guys
• ImageMagick bridges, e.g., here and here
• inkscape bridge
• rsvg using Gnome's Librsvg (using Cairo).
GWicke added a comment.EditedDec 15 2014, 4:33 PM

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.

Change 178645 abandoned by Physikerwelt:
WIP: png support for mathoid

https://gerrit.wikimedia.org/r/178645

Prod added a subscriber: Prod.Jul 20 2015, 10:30 PM
Restricted Application added a subscriber: Aklapper. Jul 20 2015, 10:30 PM

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 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?

Makes sense to have a generic svg2png service and call it when needed.

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?

matmarex removed a subscriber: matmarex.Feb 15 2016, 4:06 PM

Mathoid: enable PNG generation

https://gerrit.wikimedia.org/r/276734

mobrovac claimed this task.Mar 12 2016, 3:57 AM

PR #552 adds PNG support to RESTBase's /media/math/render/{format}/{hash} endpoint.

Change 276734 merged by Giuseppe Lavagetto:
Mathoid: enable PNG generation

https://gerrit.wikimedia.org/r/276734

mobrovac closed this task as Resolved.Mar 21 2016, 4:43 PM
mobrovac removed a project: Patch-For-Review.
mobrovac removed subscribers: gerritbot, wikibugs-l-list.

PR #552 adds PNG support to RESTBase's /media/math/render/{format}/{hash} endpoint.

The PR has been merged and deployed: RESTBase and Mathoid now support and serve PNG renders as well. Resolving.