Page MenuHomePhabricator

Score should output SVG
Open, Stalled, MediumPublic10 Estimated Story PointsFeature

Assigned To
None
Authored By
grin
Apr 23 2013, 10:14 PM
Referenced Files
F34562238: New_rendersvg.png
Jul 24 2021, 7:57 AM
F34562236: New_librsvg251.png
Jul 24 2021, 7:57 AM
F34562240: New_Inkscape.png
Jul 24 2021, 7:57 AM
F34562244: O_Canada_Lilypond.svg
Jul 24 2021, 7:57 AM
F34562242: New_batik.png
Jul 24 2021, 7:57 AM
F34562245: Bildschirmfoto von 2021-07-24 08-47-52.png
Jul 24 2021, 7:57 AM
F12070451: O_Canada_Lilypond.svg.png
Dec 26 2017, 7:30 PM
F8799700: s-fauré.svg
Jul 20 2017, 12:11 AM

Description

Svg output would be nice as it could solve all complaints about transparent background (bug T49444) and rendering size (bug T49523).

It's as easy as
lilypond ... -dbackend=svg ...
and it's _not_ using ghostscript, which is a fantastic step towards world peace.


Version: master
Severity: enhancement

Details

Reference
bz47578

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Change 370209 had a related patch set uploaded (by Ebe123; owner: Ebe123):
[mediawiki/extensions/Score@master] Output SVG in scores

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

Ebe123 changed the task status from Open to Stalled.Aug 4 2017, 11:39 PM
Ebe123 set the point value for this task to 10.

A caveat that may prove important is the treatment of text (like in tempo markings) in SVG. There are some outstanding bugs, such as issue 5174 and issue 3778 (each of them relating to text handling, specifically in tempo markings) that make SVG output less good, although it's very minor.

Further on text, the conversion, using MediaWiki's rasterizer leaves us with the problem described in T36947: Incorrect text positioning in SVG rasterization (scale/transform; font-size; kerning).

IZoid raised the priority of this task from Medium to High.
IZoid added parent tasks: T1: Get puppet runs into logstash, T38: Migrate RT to Phabricator, T7: Get icinga alerts into logstash, T110: Let users configure date format in account settings, T125: Allow viewing diffs of single commits within a Differential, T136: Pulling patches from Phabricator does not give consistent commit hashes, T141: Fork ChemDoodle Web components, improve code readablility, T207: Update Code Review related documentation on wiki pages from Gerrit to Differential, T261: Metadata fields for SMILES and InChI, T329: Use EventEmitter in Flow, T351: RfC: Square bounding boxes, T352: Run the requested stats on Square bounding boxes, T353: RFC: Vertical writing support, T356: RfC: Standardized thumbnails sizes, T359: Document the Wikidata API in the Developer Hub, T409: Editing files and contributing changes via web, T468: CentralNotice backend improvements, T500: Create basic endpoint for JS error logging, T514: Collect environment information for JS error logging, T519: Improve error id generation in JS error logging, T522: Add JS error counts to graphite, T523: Deduplicate JS error logs, T542: Improvements to Wikimedia SUL login dialog UI: Avoid HTML entities, spell "MediaWiki" account type with upper case, T555: Per-user projects for personal work in progress tracking, T623: OAuth login refers to mediawiki.org:/ instead of mediawiki.org/ (exposing unneeded port syntax), T653: Refresh the mediawiki.org homepage, T706: Requests for addition to the #acl*Project-Admins group (in comments), T715: GitHub -> Phabricator import system, T877: Add IRC name and MediaWiki Username as alternate auto-complete lookups, T882: Converted bugs could link to the original report in static-bugzilla.wikimedia.org, T949: update make-release to refuse to work if tag != $wgVersion, T1012: Add i18n for Spanish, T1032: Contact softaculous.com, T1124: Write design document for content/storage APIs, T1126: Mobile friendly OAuth permission screen when logging in to Phabricator, T1175: Get rid of screen scraping in Wikibugs, T1287: Define the architecture areas for MediaWiki core and platform extensions, T1380: Nature.com articles gives citoid 401s., T1384: Capture Javascript support level for web users, T2166: Identify redirects with CSS class *everywhere*, T2209: [DO NOT USE] HTML validity (tracking), T2235: Auto unit conversion, T2576: [OAI-PMH] Open Archives Initiative Protocol for Metadata Harvesting (tracking), T2851: when viewing an old version of a page, use old version of templates, T2980: Automatical merge of conflicting non-section edits to unintersecting sets of sections, T3007: Cartouche ends do not scale to fit the enclosed hieroglyphs, T3310: Recursive tags in extensions., T3316: Allow image thumb output format to be specified, T3340: Size thumbnails in galleries according to user preferences, T3433: Add metainformation for interlanguage links (link rel="alternate" hreflang), T182148: Ensure we are coping with deadlock Exceptions properly & our q doesn't corrupt at high volume, reduce unecessary potentially blocking queries, T3575: Support setting a #REDIRECT with a transcluded string instead of a page name, T3581: pre over multiple lines in lists, T14156: FEATURE REQUEST: Per Entry Question/FAQ/Want-to-Know so readers could ask/influence contributors, T14191: Show links to intermediate revisions rather than "(One intermediate revision not shown.)", T14341: Warning for truncation of pages to 32kb, T14490: Warning needed if dimensions of reupload differ, T182151: inform national WLE/WLAf organizers about dashboard proposal, T14535: all inter project prefixes should be resolved before « oldid= », T14610: generalize function switchPrefTab() (previously tabbedprefs()), T14653: Honour protection status in Special:Import, T14681: New messages bar should appear above page title, for consistency with other message boxes, T14804: Image missing all revisions, T14874: batch deletion for file histories, T19143: Introduce magic word that restricts certain categories (and their sub-categories) to the article namespace., T19131: Feature Request: Transclusion Preprocessing Hook, T19125: Correct rendering of ViewAPC for non-latin characters, T19090: Site notice has layout problem with links in the upper edge., T17212: Allow self-renames, T17159: Turn wikilinks different colors depending on a page's presence on this wiki AND another specified wiki (e.g. Wikipedia), T17075: Per book, category and/or template CSS and JavaScript, T17074: List, count and search all books, T17060: Make non-sensitive browser referrers available through Wikistats, T16892: Linkify plain external links in revision editsummary and log reason, T16880: Preset Special:CategoryTree input with main category., T16843: RCFeed: Send boolean flag indicating that target page is a redirect, T16720: robots.txt (tracking), T16688: User isn't allowed to upload, but there is no permission error, T16611: Special:Version should show all third party software which it depends on, T16591: Special:Linksearch should be case insensitive, T16530: Classic edit toolbar should be more accessible for change and modification, T16501: A way to hide the sidebar providing a "fullscreen" view, T16417: Generate upload log entry when duplicate file uploaded, T16281: Rename "Bad image list" to something better, T16215: Allow definition to be used as a link target, T16171: Allow Special:FileDuplicateSearch to match against previously deleted images, T15955: Include HTML meta tags for pages' Atom/RSS feeds in article view mode, T15951: Provide all URL parameters for all RSS/Atom feeds consistently, T15765: more "jump to" accessibility links needed, T15588: Track link changes / Have a log for category changes, T15466: Design of diffs should be improved to indicate white space changes better, T15303: Implement HTML e-mail support in MediaWiki, T15170: Namespace-based category specification, T15090: Add magic word to generate combined-TOC from a set of pages, T15038: Top edge of image clobbers text, T15025: New parser function / magic word, for "pretty-printed" numbers, T15698: (top) in watchlists, T182152: Get more connections for instagram account Wiki Loves Monuments, T14942: Uncategorized categories/pages/templates/files refactoring, T14896: Spam Blacklist shouldn't be fooled by similar-looking Unicode characters.Dec 9 2017, 6:34 PM
IZoid added parent tasks: T1: Get puppet runs into logstash, T38: Migrate RT to Phabricator, T7: Get icinga alerts into logstash, T110: Let users configure date format in account settings, T125: Allow viewing diffs of single commits within a Differential, T136: Pulling patches from Phabricator does not give consistent commit hashes, T141: Fork ChemDoodle Web components, improve code readablility, T207: Update Code Review related documentation on wiki pages from Gerrit to Differential, T261: Metadata fields for SMILES and InChI, T329: Use EventEmitter in Flow, T351: RfC: Square bounding boxes, T352: Run the requested stats on Square bounding boxes, T353: RFC: Vertical writing support, T356: RfC: Standardized thumbnails sizes, T359: Document the Wikidata API in the Developer Hub, T409: Editing files and contributing changes via web, T468: CentralNotice backend improvements, T500: Create basic endpoint for JS error logging, T514: Collect environment information for JS error logging, T519: Improve error id generation in JS error logging, T522: Add JS error counts to graphite, T523: Deduplicate JS error logs, T542: Improvements to Wikimedia SUL login dialog UI: Avoid HTML entities, spell "MediaWiki" account type with upper case, T555: Per-user projects for personal work in progress tracking, T623: OAuth login refers to mediawiki.org:/ instead of mediawiki.org/ (exposing unneeded port syntax), T653: Refresh the mediawiki.org homepage, T706: Requests for addition to the #acl*Project-Admins group (in comments), T715: GitHub -> Phabricator import system, T877: Add IRC name and MediaWiki Username as alternate auto-complete lookups, T882: Converted bugs could link to the original report in static-bugzilla.wikimedia.org, T949: update make-release to refuse to work if tag != $wgVersion, T1012: Add i18n for Spanish, T1032: Contact softaculous.com, T1124: Write design document for content/storage APIs, T1126: Mobile friendly OAuth permission screen when logging in to Phabricator, T1175: Get rid of screen scraping in Wikibugs, T1287: Define the architecture areas for MediaWiki core and platform extensions, T1380: Nature.com articles gives citoid 401s., T1384: Capture Javascript support level for web users, T2166: Identify redirects with CSS class *everywhere*, T2209: [DO NOT USE] HTML validity (tracking), T2235: Auto unit conversion, T2576: [OAI-PMH] Open Archives Initiative Protocol for Metadata Harvesting (tracking), T2851: when viewing an old version of a page, use old version of templates, T2980: Automatical merge of conflicting non-section edits to unintersecting sets of sections, T3007: Cartouche ends do not scale to fit the enclosed hieroglyphs, T3310: Recursive tags in extensions., T3316: Allow image thumb output format to be specified, T3340: Size thumbnails in galleries according to user preferences, T3433: Add metainformation for interlanguage links (link rel="alternate" hreflang), T182148: Ensure we are coping with deadlock Exceptions properly & our q doesn't corrupt at high volume, reduce unecessary potentially blocking queries, T3575: Support setting a #REDIRECT with a transcluded string instead of a page name, T3581: pre over multiple lines in lists, T14156: FEATURE REQUEST: Per Entry Question/FAQ/Want-to-Know so readers could ask/influence contributors, T14191: Show links to intermediate revisions rather than "(One intermediate revision not shown.)", T14341: Warning for truncation of pages to 32kb, T14490: Warning needed if dimensions of reupload differ, T182151: inform national WLE/WLAf organizers about dashboard proposal, T14535: all inter project prefixes should be resolved before « oldid= », T14610: generalize function switchPrefTab() (previously tabbedprefs()), T14653: Honour protection status in Special:Import, T14681: New messages bar should appear above page title, for consistency with other message boxes, T14804: Image missing all revisions, T14874: batch deletion for file histories, T19143: Introduce magic word that restricts certain categories (and their sub-categories) to the article namespace., T19131: Feature Request: Transclusion Preprocessing Hook, T19125: Correct rendering of ViewAPC for non-latin characters, T19090: Site notice has layout problem with links in the upper edge., T17212: Allow self-renames, T17159: Turn wikilinks different colors depending on a page's presence on this wiki AND another specified wiki (e.g. Wikipedia), T17075: Per book, category and/or template CSS and JavaScript, T17074: List, count and search all books, T17060: Make non-sensitive browser referrers available through Wikistats, T16892: Linkify plain external links in revision editsummary and log reason, T16880: Preset Special:CategoryTree input with main category., T16843: RCFeed: Send boolean flag indicating that target page is a redirect, T16720: robots.txt (tracking), T16688: User isn't allowed to upload, but there is no permission error, T16611: Special:Version should show all third party software which it depends on, T16591: Special:Linksearch should be case insensitive, T16530: Classic edit toolbar should be more accessible for change and modification, T16501: A way to hide the sidebar providing a "fullscreen" view, T16417: Generate upload log entry when duplicate file uploaded, T16281: Rename "Bad image list" to something better, T16215: Allow definition to be used as a link target, T16171: Allow Special:FileDuplicateSearch to match against previously deleted images, T15955: Include HTML meta tags for pages' Atom/RSS feeds in article view mode, T15951: Provide all URL parameters for all RSS/Atom feeds consistently, T15765: more "jump to" accessibility links needed, T15588: Track link changes / Have a log for category changes, T15466: Design of diffs should be improved to indicate white space changes better, T15303: Implement HTML e-mail support in MediaWiki, T15170: Namespace-based category specification, T15090: Add magic word to generate combined-TOC from a set of pages, T15038: Top edge of image clobbers text, T15025: New parser function / magic word, for "pretty-printed" numbers, T15698: (top) in watchlists, T182152: Get more connections for instagram account Wiki Loves Monuments, T14942: Uncategorized categories/pages/templates/files refactoring, T14896: Spam Blacklist shouldn't be fooled by similar-looking Unicode characters.

Eh, no. We still must wait for it to be released in their 2.20 (or 2.22 if
there's bad luck) stable, and still have to implement it in the MediaWiki-extensions-Score
extension. Re-opening.

Ebe123 removed parent tasks: T14896: Spam Blacklist shouldn't be fooled by similar-looking Unicode characters, T14942: Uncategorized categories/pages/templates/files refactoring, T182152: Get more connections for instagram account Wiki Loves Monuments, T15698: (top) in watchlists, T15025: New parser function / magic word, for "pretty-printed" numbers, T15038: Top edge of image clobbers text, T15090: Add magic word to generate combined-TOC from a set of pages, T15170: Namespace-based category specification, T15303: Implement HTML e-mail support in MediaWiki, T15466: Design of diffs should be improved to indicate white space changes better, T15588: Track link changes / Have a log for category changes, T15765: more "jump to" accessibility links needed, T15951: Provide all URL parameters for all RSS/Atom feeds consistently, T15955: Include HTML meta tags for pages' Atom/RSS feeds in article view mode, T16171: Allow Special:FileDuplicateSearch to match against previously deleted images, T16215: Allow definition to be used as a link target, T16281: Rename "Bad image list" to something better, T16417: Generate upload log entry when duplicate file uploaded, T16501: A way to hide the sidebar providing a "fullscreen" view, T16530: Classic edit toolbar should be more accessible for change and modification, T16591: Special:Linksearch should be case insensitive, T16611: Special:Version should show all third party software which it depends on, T16688: User isn't allowed to upload, but there is no permission error, T16720: robots.txt (tracking), T16843: RCFeed: Send boolean flag indicating that target page is a redirect, T16880: Preset Special:CategoryTree input with main category., T16892: Linkify plain external links in revision editsummary and log reason, T17060: Make non-sensitive browser referrers available through Wikistats, T17074: List, count and search all books, T17075: Per book, category and/or template CSS and JavaScript, T17159: Turn wikilinks different colors depending on a page's presence on this wiki AND another specified wiki (e.g. Wikipedia), T17212: Allow self-renames, T19090: Site notice has layout problem with links in the upper edge., T19125: Correct rendering of ViewAPC for non-latin characters, T19131: Feature Request: Transclusion Preprocessing Hook, T19143: Introduce magic word that restricts certain categories (and their sub-categories) to the article namespace., T14874: batch deletion for file histories, T14804: Image missing all revisions, T14681: New messages bar should appear above page title, for consistency with other message boxes, T14653: Honour protection status in Special:Import, T14610: generalize function switchPrefTab() (previously tabbedprefs()), T14535: all inter project prefixes should be resolved before « oldid= », T182151: inform national WLE/WLAf organizers about dashboard proposal, T14490: Warning needed if dimensions of reupload differ, T14341: Warning for truncation of pages to 32kb, T14191: Show links to intermediate revisions rather than "(One intermediate revision not shown.)", T14156: FEATURE REQUEST: Per Entry Question/FAQ/Want-to-Know so readers could ask/influence contributors, T3581: pre over multiple lines in lists, T3575: Support setting a #REDIRECT with a transcluded string instead of a page name, T182148: Ensure we are coping with deadlock Exceptions properly & our q doesn't corrupt at high volume, reduce unecessary potentially blocking queries, T3433: Add metainformation for interlanguage links (link rel="alternate" hreflang), T3340: Size thumbnails in galleries according to user preferences, T3316: Allow image thumb output format to be specified, T3310: Recursive tags in extensions., T3007: Cartouche ends do not scale to fit the enclosed hieroglyphs, T2980: Automatical merge of conflicting non-section edits to unintersecting sets of sections, T2851: when viewing an old version of a page, use old version of templates, T2576: [OAI-PMH] Open Archives Initiative Protocol for Metadata Harvesting (tracking), T2235: Auto unit conversion, T2209: [DO NOT USE] HTML validity (tracking), T2166: Identify redirects with CSS class *everywhere*, T1384: Capture Javascript support level for web users, T1380: Nature.com articles gives citoid 401s., T1287: Define the architecture areas for MediaWiki core and platform extensions, T1175: Get rid of screen scraping in Wikibugs, T1126: Mobile friendly OAuth permission screen when logging in to Phabricator, T1124: Write design document for content/storage APIs, T1032: Contact softaculous.com, T1012: Add i18n for Spanish, T949: update make-release to refuse to work if tag != $wgVersion, T882: Converted bugs could link to the original report in static-bugzilla.wikimedia.org, T877: Add IRC name and MediaWiki Username as alternate auto-complete lookups, T715: GitHub -> Phabricator import system, T706: Requests for addition to the #acl*Project-Admins group (in comments), T653: Refresh the mediawiki.org homepage, T623: OAuth login refers to mediawiki.org:/ instead of mediawiki.org/ (exposing unneeded port syntax), T555: Per-user projects for personal work in progress tracking, T542: Improvements to Wikimedia SUL login dialog UI: Avoid HTML entities, spell "MediaWiki" account type with upper case, T523: Deduplicate JS error logs, T522: Add JS error counts to graphite, T519: Improve error id generation in JS error logging, T514: Collect environment information for JS error logging, T500: Create basic endpoint for JS error logging, T468: CentralNotice backend improvements, T409: Editing files and contributing changes via web, T359: Document the Wikidata API in the Developer Hub, T356: RfC: Standardized thumbnails sizes, T353: RFC: Vertical writing support, T352: Run the requested stats on Square bounding boxes, T351: RfC: Square bounding boxes, T329: Use EventEmitter in Flow, T261: Metadata fields for SMILES and InChI, T207: Update Code Review related documentation on wiki pages from Gerrit to Differential, T141: Fork ChemDoodle Web components, improve code readablility, T136: Pulling patches from Phabricator does not give consistent commit hashes, T125: Allow viewing diffs of single commits within a Differential, T110: Let users configure date format in account settings, T7: Get icinga alerts into logstash, T38: Migrate RT to Phabricator, T1: Get puppet runs into logstash.
Aklapper lowered the priority of this task from High to Medium.Dec 9 2017, 6:38 PM
Ebe123 changed the task status from Open to Stalled.Dec 22 2017, 8:06 PM

The new -dcrop option will be in the next stable release (2.20), which may be in the next few months.

After this blocker, there is also the problem with librsvg, which renders text in SVG scores very badly. As an example:

O_Canada_Lilypond.svg.png (556×689 px, 42 KB)

Updating librsvg is another block here, notwithstanding further text improvements needed in lilypond, such as with skylines, but that is much less severe.

In T49578#3857903 back in 2017, @Ebe123 wrote:

The new -dcrop option will be in the next stable release (2.20), which may be in the next few months.

Debian 10 (buster?) backports has Lilypond 2.22.0, so perhaps this should depend on a task to update Lilypond? Lilypond itself is now at 2.22.1, with some worthwhile improvements including I think a new -svg command-line option.

Thanks for all y'all do ❣

After this blocker, there is also the problem with librsvg, which renders text in SVG scores very badly. As an example:

O_Canada_Lilypond.svg.png (556×689 px, 42 KB)

Updating librsvg is another block here, notwithstanding further text improvements needed in lilypond, such as with skylines, but that is much less severe.

Because most Score operations now run in a container, it's a lot more straightforward for us to use a newer librsvg without affecting all other SVG rendering.

The most recent comment in T36947 said "librsvg 2.51.2 (and librsvg 2.50.6, once backported)" - could you retry it with one of those versions to see if it's fixed now?

@Legoktm T36947 is very system-dependend and differ between OS and on different scalings. For https://commons.wikimedia.org/wiki/File:O_Canada_Lilypond.svg you just need to upscale the fonts as done in https://commons.wikimedia.org/wiki/File:O_Canada_Lilypond_Workaround.svg, or described at https://en.wikipedia.org/wiki/Wikipedia:SVG_help#bad_letter-alignment_on_small_font-size.

Rendering of

rust-librsvg2.50.6resvgInkscapebatik
New_librsvg251.png (593×735 px, 87 KB)
New_rendersvg.png (593×735 px, 98 KB)
New_Inkscape.png (593×735 px, 101 KB)
New_batik.png (593×735 px, 87 KB)

Bildschirmfoto von 2021-07-24 08-47-52.png (656×1 px, 323 KB)

librsvg must be packed for debian stretch/buster, since librsvg is on stretch on 2.40 and on buster on 2.44, see https://packages.debian.org/search?keywords=librsvg2 .

resvg, Inkscape and batik are portable or have portable Images, so they do not depend on system-libaries. Therefore it is imho much easier to change svg-renderer (see T40010 ) than to package rust-librsvg2.50.6 (imho depends on cairo, glib, gtk) . I personally prefer to switch to resvg, see svg-benchmarks .

Thank you for the comparison @JoKalliauer, I think we could probably get resvg into the Score/Shellbox container, that said...do we actually need a separate SVG renderer? Could we continue to have LilyPond generate PNGs in addition to SVG? And display to users the SVG with PNG fallback?

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM

Is there anything I can do to help this along? I'm a PHP dev with a little time on my hands currently, but it seems as if this is more to do with aligning SVG rendering libs on container OSes? Let me know if I can help in some way. Is this changeset still useful, or has it been superceded by more recent work?

Message from Han-Wen Nienhuys, August 2021 to lilypond-devel:

* SVG.

  The current SVG backend is glacially slow, and has suffered from
  rendering discrepancies. I propose we retire it ASAP to be
  replaced by Cairo. The only feature missing is the 'svg-woff option;
  not sure how important that is? (CC'ing Jan who implemented this.)

    [hanwen@fedora lilypond]$ time lilypond --svg
input/regression/les-nereides.ly
    GNU LilyPond 2.23.4
    ..
    real 0m1.662s
    [hanwen@fedora lilypond]$ time lilypond  --svg -dbackend=cairo
input/regression/les-nereides.ly
    GNU LilyPond 2.23.4
    ....
    real 0m0.728s

  The Cairo SVG files are larger, but that is because they also embed
  the fonts used for texts, making the rendering exactly equal to the
  PDF/PNG.

I would suggest not using the old SVG backend since it is rarely used and effectively deprecated. It doesn't embed fonts, so rendering depends on the browser. The well-trodden path is to treat LilyPond as a PostScript generator.

The Cairo backend could be used. It is currently disabled by default, but at least if we use it and find bugs, there might be some interest from upstream in fixing them. It has had 16 commits this year.

In other words, the LilyPond backends are:

  • PostScript: stable and used by just about everyone
  • SVG: a deprecated curiosity
  • Cairo: the bleeding edge future, can output to SVG or PNG

Is there anything I can do to help this along? I'm a PHP dev with a little time on my hands currently, but it seems as if this is more to do with aligning SVG rendering libs on container OSes? Let me know if I can help in some way. Is this changeset still useful, or has it been superceded by more recent work?

There's plenty to do in PHP. I would suggest installing MediaWiki, Score and a locally compiled LilyPond with Cairo enabled. Then investigate the possibility of using the Cairo backend to generate both SVG and PNG. There is not much in commit 370209 that would stay the same, so it might be easier to start from scratch.

Ebe123 subscribed.

Noting here the upstream progress on including the Cairo backend in Lilypond by default: merge request 1610, and lilypond-devel discussion thread.

I have a sneaking suspicion that unless we are really still wanting to support really old unsupported browsers, like Internet Explorer 11, we really don't need a PNG fallback. SVG images are supported by basically all of the things, and even IE 11 is passable as long as the SVG is not animated:
https://caniuse.com/?search=svg

Comments on this would be welcome, because if we don't need PNG then we can circumvent using --ps and depending on GhostScript. Update: see also T5593

I have got a small initial commit with SVG support working nicely, using the upcoming December release of Lilypond 2.24 (currently testing on 2.23.82 with libcairo). I am using the -dno-use-paper-size-for-page option (if $wgScoreTrim` is true) to do what all the existing trim and size detection code is doing (since -dcrop does not quite work as we need). If phabricator will allow me, I'll try pushing a feature branch to Gerrit, otherwise I'll stash it on GitLab somewhere for someone to have a look at.

I am currently working on getting the multi-page output working as before. I have no idea if the test suite is passing yet, so it's still early days :)

I can't seem to be able to push to Gerrit; in the meantime, the very basic diff is displayed here on GitLab. This should work as long as you have a 2.24 RC version of Lilypond; I have been testing with the 2.23.82 release.

Here's a 1.35 instance with the 1.35 SVG patch installed:
https://rel1-35.home.jon.geek.nz/wiki/Score_examples

Compare, the current PNG output, here:
https://wiki.jon.geek.nz/Score_examples

I can't seem to be able to push to Gerrit

@Jonathanischoice: Thanks for taking a look at the code! Could you please elaborate on the problem in a support forum? Usually developer access should allow you to submit proposed code changes as a Git branch into Gerrit; if you don't want or cannot set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks again!

@Aklapper - I get this, and I'm not sure where/who to post or contact:

remote: error: branch refs/heads/generate-svg:
remote: You need 'Create' rights to create new references.
remote: User: jonathanischoice
remote: Contact an administrator to fix the permissions
remote: Processing changes: refs: 1, done    
To ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score
 ! [remote rejected] generate-svg -> generate-svg (prohibited by Gerrit: not permitted: create)
error: failed to push some refs to 'ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score'

@Jonathanischoice you should use git-review to upload changes. It is not possible to push to refs/heads/*, you need to push to refs/for/* to create a change for review, which git-review takes care of.

Ah yes... I remember now. It's been years since I used gerrit... oh, and I need to rebase to master, which will take a while because change

Change 862408 had a related patch set uploaded (by Jonathanischoice; author: Jonathanischoice):

[mediawiki/extensions/Score@master] Get SVG output working for cropped, non-paginated input, T49578

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

This is still a WIP:

  • after the rebase to master, I followed my nose and removed the shell trim code that uses convert, and thus also the ImageMagick dependency altogether.
  • I'm still working on paginated output, which is also trimmed correctly in both the SVG and PNG, but it is not currently adding the SVG page images.
  • I haven't even looked at the tests yet, so I guess they'll be failing; so much for TDD :)
  • I suspect that just using --png instead of deriving them from --ps will also make a bunch more code redundant, and even remove the GhostScript dependency, but I haven't tried that yet.

@Jonathanischoice just an fyi. You don't need to delete a translation key from every language dictionary. If you remove it from en and qqq, the rest will be taken care of automatically. https://www.mediawiki.org/wiki/Help:System_message#Removing_existing_messages

I've resolved several things, and pushed an update to Gerrit. I've also found that we don't even need the --ps output and GhostScript any more, because we can fetch the same page size information from the <svg> attributes.

Change 863576 had a related patch set uploaded (by Jonathanischoice; author: Jonathanischoice):

[mediawiki/extensions/Score@master] Get page dimensions from SVG instead of PostScript, T49578

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

I've pushed two commits ready for review - @TheDJ and @tstarling. Still not sure what the procedure is here; it's been ages since I've had to use Gerrit. Test instance here.
Also: is it worth smooshing them together into one commit?

Change 863576 abandoned by Jonathanischoice:

[mediawiki/extensions/Score@master] Get page dimensions from SVG instead of PostScript, T49578

Reason:

Have squashed this into the first commit, see T49578

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

Ok, so it turns out we don't even need to get the page size at all, because that was only being used by GhostScript to generate the PNG from the PS output, which we're not doing in this patch. Have pushed an all-in-one commit to Gerrit. I can't see how to easily add a comment to a Gerrit MR, hence the chattiness here (sorry?)

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

Change 862408 merged by jenkins-bot:

[mediawiki/extensions/Score@master] Use LilyPond with libcairo to generate SVG and PNG directly, T49578

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

Hooray :) Now I have a thought about what to do with the existing PNG renders that are being used on pages until they are next edited. Is it possible to create some sort of maintenance task that can process the image store in the background, generating any missing SVG files using the preserved LilyPond file?

Change 868532 had a related patch set uploaded (by Reedy; author: Jonathanischoice):

[mediawiki/extensions/Score@REL1_39] Use LilyPond with libcairo to generate SVG and PNG directly, T49578

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

Change 868532 merged by jenkins-bot:

[mediawiki/extensions/Score@REL1_39] Use LilyPond with libcairo to generate SVG and PNG directly, T49578

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

Change 370209 abandoned by Ebe123:

[mediawiki/extensions/Score@master] Output SVG in scores

Reason:

Sure

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

Noting here that LilyPond 2.24.0 was released 16 December 2022 - changes. Shall we boldly create an "Update LilyPond in Shellbox container to 2.24" task, similar to the previous one?

This was merged over 2 months ago, what happens next? I'd like to get T134455 advanced so we can get on with SVG Score output somehow.

So you want to move this to WMF production ?

I see at least two follow up tasks for that:

  1. Update the shellbox container with a new version of lilypond
    1. This seems complicated by the fact that last time @Legoktm tried to update, the updated package for lilypond wasn't in the version of Debian used yet, and making their own version seemed a challenge.
  2. Make a deploy plan
    1. Find a WMF deployer willing to assist you
    2. Deploy the new version of the shellbox container and make sure there are no regressions
    3. Modify the WMF configuration for the beta cluster to use the new config via a patch on the operations repo
    4. Setup a page in beta cluster with various score usages to verify everything works as expected
    5. Modify the WMF configuration to use the new option for deploy group 0
    6. Setup a page on test.wikipedia.org with various score usages to verify everything works as expected
    7. Make an announcement in Tech-news via User-notice
    8. Modify the WMF configuration to use the new option for deploy group 1
    9. Modify the WMF configuration to use the new option for deploy group 2

also..

I'd like to get T134455 advanced so we can get on with SVG Score output somehow.

I'm not sure what these two things have to do with eachother. The file thumbnailing architecture is fully separate from the Score images isn't it ?

You'll have to forgive my total lack of knowledge of Wikipedia internals and toolchains since I'm not an employee, I'm just a Wikipedia editor with an overinflated sense of enthusiasm and can code in PHP, so I offered to help with the Score extension. I'm not sure I'd be much use for most of that?

Noting here that LilyPond 2.24.0 was released 16 December 2022 - changes. Shall we boldly create an "Update LilyPond in Shellbox container to 2.24" task, similar to the previous one?

Yes please. TheDJ is right that last time it was a mess and I gave up, but it's certainly worth another shot. Worst case we just have to wait a bit longer until we can use the bookworm 2.24 package.

Surely we can just pull the official upstream binary tarball from GitLab, extract it somewhere, and point LocalSettings.php variables at it? No Debian package required.

Surely we can just pull the official upstream binary tarball from GitLab, extract it somewhere, and point LocalSettings.php variables at it? No Debian package required.

Our standard practice is to prefer using Debian packages when possible as it reduces the work we need to do and lets us take advantage of Debian's security support, etc. (also a growing number of Wikimedia devs are also Debian contributors, including myself, so it's a reciprocal relationship).

lilypond is deployed in a container (current config: https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/libs/Shellbox/+/refs/heads/master/.pipeline/blubber.yaml#84), so we have a good amount of flexibility in building it ourselves, but last time I tried there were weird complications related to needing a specific guile version that Debian had dropped or something.

(This is not to rule out using an upstream binary, I think we do that in a few other places that I can't remember off the top of my head, I just think that should be a last resort.)

Fair enough. there seems to be promising recent activity on 1026200 anyway

Given the patch on T208578, should we adjust Score's behaviour around serving SVG? So, rather than use srcset (see T134455) to provide SVG with a PNG fallback, we look for the new $wgSVGNativeRendering setting and just serve SVG directly. We'll still need Lilypond to generate PNG, but it is only served for older versions of Mediawiki (using the current srcset behaviour) or where the SVG generated by Lilypond exceeds the new $wgSVGNativeRenderingSizeLimit setting. Another possibility (useful for older versions of Mediawiki) is to detect the presence of the NativeSVGHandler extension and serve SVG directly if enabled. Thoughts?

@Legoktm @TheDJ - is this likely to happen soon? I'm not sure I can help further other than annoy you by pinging... :-/

... have I gone mad, or have the Debian packages of lilypond 2.24 left out libcairo support? Is this some sort of torture?
Update: I have submitted a Debian bug regarding missing libcairo support in the lilypond 2.24 package.