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

Use librsvg for PNG rendering #16

Merged
merged 7 commits into from
Feb 26, 2016
Merged

Use librsvg for PNG rendering #16

merged 7 commits into from
Feb 26, 2016

Conversation

physikerwelt
Copy link
Member

* Remove batik support
* Use librsvg
* Breaking change: Requires additional package
  librsvg2-dev see https://www.npmjs.com/package/librsvg
@physikerwelt
Copy link
Member Author

@wikimedia/math this is a really huge performance benefit, and no temp files for png images anymore

@physikerwelt
Copy link
Member Author

cc @pkra

* Get the dimensions for the PNG image
* Make PNG images slightly bigger.
* Scaling factor 2 was chosen as default
@pkra
Copy link

pkra commented Feb 15, 2016

Thanks for the cc. I'm guessing that means you want to submit this upstream at mathjax-node as well? The first question that comes to mind: could you abstract the converter? It'd be great if people could switch out their personal favorite, in particular svg2png is a fan favorite.

@pkra
Copy link

pkra commented Feb 15, 2016

But it would be good to make a PR on mathjax-node to discuss this further.

Oh and also: really great to see this! 💯

@physikerwelt
Copy link
Member Author

@pkra I would love to make that this modular. I was thinking about that, but I'm not not sure what's the best way to do this. Maybe @d00rman has an idea.
With this change the performance improves drastically
physikerwelt/mathoid-server@5169289
However, there is additional effort required to make this run on windows. Took me about 1 hour, but only since I called by directory "C:\GTK" instad of "C:\gtk" which is the same for windows but not for node.

@pkra
Copy link

pkra commented Feb 15, 2016

I was thinking about that, but I'm not not sure what's the best way to do this.

Maybe discuss upstream?

@@ -1,5 +1,13 @@
-sudo: false
language: node_js
node_js:
- "4.2.4"
- "4.2"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to keep 4.2.4 because that's the version used in WMF prod.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. But we should keep that consistent. I think in other repos we have just 4.2

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll soon switch to node 4.3, so you might as well put that instead :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could specify just "4", which pulls in the latest 4.x automatically.

@d00rman
Copy link

d00rman commented Feb 17, 2016

In principle, I welcome this change, but I'm afraid WMF isn't ready for it. We have our own pkgs for librsvg which don't currently exist for Jessie :/ We need to follow up on this, though.

@physikerwelt
Copy link
Member Author

@d00rman did you file a bug for librsvg-dev? I think the absence of PNG export is the most important blocker for further developments in the math environment. We might consider taking a special path for math since we do not feed arbitrary svg images to librsvg.

@pkra
Copy link

pkra commented Feb 17, 2016

Give me a day to finish up some work for an upstream modularization of the png generation.

@d00rman
Copy link

d00rman commented Feb 17, 2016

@physikerwelt I've just spoken to @Stype about it, and he says that the newest Jessie librsvg contain all of our security fixes, so we are actually good to go on that front. libsrvg2-dev is present in Jessie.

@d00rman
Copy link

d00rman commented Feb 17, 2016

@physikerwelt module the minor Travis config nits, LGTM, so when these are corrected I'd be happy to merge.

@@ -1,6 +1,6 @@
{
"name": "mathoid-mathjax-node",
"version": "0.5.0",
"version": "0.5.1",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since this a breaking change, v0.6.0 would be more appropriate.

});
return synch; // This keeps the queue from continuing until the readFile() is complete
}
var Readable = require('stream').Readable;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why this is not in the file's header?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no not really.Should I move it?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@d00rman done

var svgFile = result.svgfile; delete result.svgfile;
var width = result.width; delete result.width;
var height = result.height; delete result.height;
if (data.png) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If data.png is false-y, no return is specified. Shouldn't synch be retuned anyway?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change that...

Replace delete with "= undefined".
d00rman pushed a commit that referenced this pull request Feb 26, 2016
Use librsvg for PNG rendering
@d00rman d00rman merged commit 5dd8bb0 into wikimedia:master Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants