lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Embedding images into a score created with -dbackend=svg


From: Valentin Petzel
Subject: Re: Embedding images into a score created with -dbackend=svg
Date: Sat, 27 Nov 2021 03:51:07 +0100

Hello Paolo,

The viewer needs to rasterize the svg, how else is it supposed to display it?
Also it’s not you who is supposed to add the image tag, but the svg backend.

But then in your example you are basically doing thing you do not need to do. 
Embedding svgs would be interesting for custom graphics and stuff, but not for 
embedding Lilypond output into Lilypond. Why don’t you just directly write 
this in one step using all Lilypond? There is nothing on this example page 
that would require importing anything.

If you want to have a score in some markup, just do
\markup { bla bla bla \score{ ... } bla bla }

And the problem with your approach of turning an svg into a Lilypond path is 
than the lilypond drawing commands are significantly less powerful than SVG. 
So you cannot process all graphics files using your method.

Cheers,
Valentin

Am Samstag, 27. November 2021, 03:35:39 CET schrieb Paolo Prete:
> On Fri, Nov 26, 2021 at 7:18 PM Valentin Petzel <valentin@petzel.at> wrote:
> > Hello Paolo,
> > 
> > I’m not exactly sure what you mean by „inline-svg”. The discussion you
> > linked
> > to is about manually converting svg paths into lilypond paths. While this
> > is
> > possible it surely would get very complicated with more advanced svg.
> > 
> > But it should be quite easy to use the <image>-tag svg gives us by it’s
> > specifications to embed any sort of jpeg, png or svg image.
> 
> Hello Valentin,
> 
> using the <image> tag has one big disadvantage, at least in my case, AFAIK:
> it can easily happen that the embedded image is automatically rasterized by
> the viewer. See:
> https://stackoverflow.com/questions/30582159/avoiding-rasterization-with-svg
> -image-so-that-transforms-work-in-firefox .
> In addition: how would I create the <image> tag with Lilypond? If I have to
> do manipulation on the svg file after it is created by LilyPond, then I
> would prefer inline svg, which means: nesting a <svg> tree inside another
> <svg> tree (<svg>...<svg></svg>...</svg>). Then I would avoid rasterization
> (and I would not have clashing ids, AFAIK). But I still prefer to do all on
> the LilyPond side, not after the output is created.
> Let's consider my specific case. I have to put some measures with few notes
> as examples on the initial pages of the score. Something like this (+ staff
> lines and clefs):
> 
> http://www.jameselkins.com/pianofiles/wp-content/uploads/2014/10/Screen-Shot
> -2014-10-29-at-11.11.39-AM-1024x653.jpg
> 
> I think the best solution is to convert svg paths to LP paths. I just found
> a very useful tool for Inkscape, which transforms SVG paths in a way that
> can be quite easily converted to LP paths:
> 
> https://github.com/Klowner/inkscape-applytransforms
> 
> Here is my (alfa) procedure:
> 
> 1) create a snippet and save it as snippet.ly. Compile it with SVG backend
> (output file: snippet.svg)
> 2) process snippet.svg with CLI of Inkscape (with the Klowner transform
> filter), so to convert all the objects to path (output file:
> snippet-paths-only, tested on Linux, Inkscape 1.1)
> 
> inkscape --batch-process
> --actions="select-all;ObjectFlipVertically;object-to-path;select-all:all;com
> .klowner.filter.apply_transform.noprefs;export-filename:snippet-paths-only.s
> vg;export-do" snippet.svg
> 
> 3) feed a script which translates snippets-path-only.svg to LilyPond syntax
> (output file: snippet-to-markup.ly). I created a "svg-paths-to-ly-paths.py"
> script for this job:
> 
> python3 svg-paths-to-ly-paths.py snippet-paths-only.svg snippet-to-markup.ly
> 
> 4) compile snippet-to-markup.ly with LP and voila.
> 
> First results are very promising, and I can already use this system for
> real cases. The size of the stems can be more accurate, but there's an easy
> fix for this: replacing the <rect> associated to the stem with a <line>, so
> to have a proper conversion of the object to a <path>.
> 
> I attach to this message all the files of my test.
> 
> Best,
> P

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]