On Wed, 10 Sep 2014 02:11:45 +0200, Jon Robson jrobson@wikimedia.org wrote:
- Trevor is going to look into how we can automatically generate
different colour versions of SVGs and automatically create PNGs from them.
Trevor any updates?
I took a stab at that after chatting with Trevor.
tl;dr it's happening!
OOjs UI now has a Grunt task [1] to generate PNG versions of SVG icons (just run `grunt` in the console and see the converted files appear in the dist/ directory). This is merged and used in production already, and would be trivial to adapt to any other repository.
There is a proof-of-concept patch for a SVG colorizer task, too [2] (run `grunt` to try it out). Right now all it does is generate variously colored versions of icons according to rules specified in Gruntfile.js; Trevor was meaning to extend it to generate necessary CSS rules and to accept configuration from a JSON file. If you're willing to write the LESS/CSS by hand, you can probably use it already. (The icons are naturally also converted to PNG by the task from the previous paragraph.)
(To run grunt tasks, you need to have Node.JS, NPM and Grunt installed, then run `npm install` in the root of any repository you want to use them in to install all task dependencies.)
There are some "prebuilt" libraries to do this, like Grunticon or Iconizr, but they all have very strong unoverridable conventions about the outputs and inputs that don't match our own. They insist on generating CSS sprites, store color information in file names, or alternatively don't allow for limiting available colors, and don't cooperate with MediaWiki's SVG+PNG fallback method.
[1] https://gerrit.wikimedia.org/r/#/c/158386/ [2] https://gerrit.wikimedia.org/r/#/c/158444/