We sometimes use a single monochrome SVG image in different colors, which requires the use of different SVG files. For example, Wikimedia Commons has so many checkmarks with different colors that we have a template to list them. Yet, most are monochrome and could be dynamically derived from just the black version.
It would save us time if MediaWiki offered a way to show an SVG in a different color, which at least didn't require to change every variant when the (typically B&W) original/master file evolves.
Option 1
Enhance the [[File:]] syntax adding a "color=" attribute to allow recoloring on-the-fly the (typically B&W) source SVG, generating the same image but in a different color, rather than having to adapt the file, upload the variant, then maintain multiple versions.
Positives:
- Reducing the duplication of same files differing only by color.
- More user friendly - no need to work with the file anymore.
The generated file will be stored then like:
<server>/path/to/thumb/<hash1>/<hash2>/<filename>/<size>px_<4colorhexRGBA>-<filename>.png
So for instance for green File:AddSpeechbubble icon.svg it will be
[[File:AddSpeechbubble icon.svg|240px|color=#0f0|Icon]]
https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/AddSpeechbubble_icon.svg/240px_00ff0000-AddSpeechbubble_icon.svg.png
Complications:
- tinting ability might need to be added to thumbor for Wikimedia production usage
- as with size, page, etc this can create a large number of derivative files that need to be cleared on modification, but this should work with existing support
- tinting/coloring alone might not be enough, we might need other features...
- might be an extra complication to support that extra parameter in front-end tools
librsvg version 2.47.3 and ulterior would facilitate that avenue.
Option 2
Create a more general "derivative files" concept allowing 'virtual' modified files to be created from on-wiki sources, such as with a color tint (among other possibilities outside the narrow scope here). The derivative file can then be used with a direct [[File:]] usage as if it were any other file.
Complications:
- need a UI for generating derivative files and saving them into the system
- probably want an API for that too!
- how many modification features to support? complexity/usability/safety concerns
- thumbor considerations:
- if MediaWiki generates the derivative master, then thumbor only needs to handle the thumbnails from a master, perhaps?
- or do all derivation through thumbor, more complex
- would URL structure of the generated files look the same as those with raw sources? If so, should work well with existing front-end tools?
Option 3
Add an explicit way to mark derivative files, with the implementation of tinting/cropping/etc left to extensions or bot tools for now. (cf DerivativeFX)
Option 4
Let templates / Lua modules generate SVG (sanitized for safety) and leave templating/tinting/etc to those templates to deal with. Also usable for graphics and things (compare with https://en.wikipedia.org/wiki/Module:Chart HTML charts!)