Inkscape.org
Beginners' Questions Is there a Path to Stroke function?
  1. #1
    OookLout OookLout @OookLout

    There is a function Object to Path, and Stroke to Path, but is there a Path to Stroke?

    I draw sketches on my portable Intuos Paper tablet, and then save them as SVGs using Wacom's 'Inkspace' utility app. When I import these SVGs into InkScape, all lines are ~0.265mm wide filled paths, OK. Adjusting and tidying these sketches using the node editor is made complicated because every penstroke is two lines of nodes and a fill. It would be better if they were all single strokes initially no fill, ie Open Paths.      

    I really would love to know how to convert each regular filled (two-stroke) path to a single stroke which follows the centreline of the original shape - a bit like like shrinking the width-distance between the two strokes to zero, so there is only one line of nodes not two.  

    ( I have tried converting to a bitmap and using Trace Bitmap but of course it is never perfect and the result is all closed Paths anyway, making it just as hard to edit.) 

    Thanks

  2. #2
    Xav Xav @Xav👹
    👍

    The closest is, I think, Trace Bitmap, but using a centerline tracing option. It's now a standard feature of 1.x - select "Single scan" then in the pop-up below you should find an option for "Centerline tracing (autotrace)".

    Remember that there's also Edit > Make a Bitmap Copy, which is a convenient way to convert your path to a bitmap for tracing, without having to export a PNG then load it back in.

  3. #3
    inklinea inklinea @inklinea⛰️

    There seems to be some export options you can tweak in Inkspace.

    Are you able to post a sample SVG - maybe someone has already written a script to solve it.

  4. #4
    OookLout OookLout @OookLout

    Quote >> ... post a sample SVG'

    A sample SVG is simplicity to generate - just draw a short path with the Pen tool. 

    I don't know of any related settings in Wacom Inkspace - I'll take another look. 

    I have a tiny SVG picture of what I require but haven't worked out how to post it here! - must be in the FAQ :-) I'll look

    I just spent a day fixing up part of a drawing, and the ease of altering the open node strokes as opposed to moving closed paths around was huge.

    I guess if most users don't draw by hand this missing function has never been considered. 

  5. #5
    inklinea inklinea @inklinea⛰️

    My relative has one of these devices, but due to social distancing I can't see them at the moment. 

    I tried to simulate the same effect.

    I found that by clearing the fill, enlarging the stroke until the two lines meet with no gap, then resize that path to 5 x times its normal size before using Alt+B, then bitmap trace (centreline trace) gave a reasonable result. I didn't include the massive bitmap for file size reasons.

    Paracurve
  6. #6
    darrepac darrepac @darrepac

    I am here cause the same day I asked a similar question: https://inkscape.org/forums/questions/get-the-middle-of-paths/

    Solutions here sounds interesting and not far from what I already tried (yet you make me discover the bitmap copy function)

    Yet, @Xav  @inklinea , if I increase too much the area of my drawing before to make a bitmap copy (in order to maximize the quality of the input of the tracing), the centerline algorithm is crashing :(

    By increasing by 2 the area, it works, but the result is not really perfect. May-be by fine tuning parameter of centerline, it could make it but it is not really self explanatory. Yet I am still wondering if there is not a function I miss that could do the trick. I put my svg file attached.

    To remind, I would like to move from this (2 paths filled):

     

    Seems like one path, but is 2 in fact when you play with stroke and fill:

     

    So my wish would be to get one path from it (centerline is perfect)

    Fox Mod
  7. #7
    inklinea inklinea @inklinea⛰️

    I had a few attempts at centreline tracing the fox yesterday.

    The results were not fantastic.

    I found that creating the bitmap (alt+b) from a 3000px wide version of the SVG did improve things. This worked in Ubuntu Inkscape 1.0.1, but crashed Windows Inkscape 1.0.1

    I also ran it through a free program called F-Engrave https://www.scorchworks.com/Fengrave/fengrave.html which runs a v-bit ( cone shaped tool ) between the two lines, a cone should vary in depth but always give centre. It was slightly better I think, but it produced a lot of random tabs that poked out. Removing them would take ages.

    I also tried opening the image in GIMP, enlarging it to 5000px + width , selecting by colour then shrinking the selection until the smallest lines in the image ( the lines in the eyes ) still had an unbroken selection.

    Then importing that into Inkscape and doing centreline trace - it did seem to give improved results, perhaps because the lines were closer together to begin with.

  8. #8
    Dragon_Ronin Dragon_Ronin @Dragon_Ronin

    In doing a lot of tracing for Inkscape, I use Gimps masking converted to paths and exported as an SVG \

  9. #9
    OookLout OookLout @OookLout

    NOTE: In my posts, I refer to a Path as a pair of lines forming an (optionally filled) loop between two or more vertices; and a Stroke as a single line between a pair of vertices. Is this agreed in the Inkscape world?

  10. #10
    OookLout OookLout @OookLout
    *

    Here is a proposal to provide a 'Path to Stroke' workaround partner to the existing Stroke to Path command.

    If you try to use the Path/Inset command, you might expect it to reduce a Path's width to a certain minimum, perhaps 0. This would be equivalent to a centreline trace. 

    Currently, the Path/Inset function is broken when the path width is reduced below a certain width, possibly the software doesn't elegantly handle it when the width goes negative?  It certainly 'blows up' and splits the original Path into blobby little islands (which, while artistic, isn't very useful or intuitive).  

    Logically, successive Path/Inset commands should reduce a Path's width until some part of its width becomes zero, then it should stop reducing the width, and offer the option of returning the whole path as a single-width stroke (using centreline tracing on the non-zero width parts). 

     

  11. #11
    Tyler Durden Tyler Durden @TylerDurden
    OookLout

    Is this agreed in the Inkscape world?

    Not really.

    Paths are the underlying geometry that creates most svg objects, consisting of lines, curves, arcs etc. Other svg objects may be shapes: rectangles, ellipses, circles, polygons, stars, etc.

    http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Shapes.html

    http://tavmjong.free.fr/INKSCAPE/MANUAL/html/Paths.html

  12. #12
    OookLout OookLout @OookLout
    *

      OK I understand that paths and shapes are the 'primitives'. They consist of lines and bezier curves between nodes, and are optionally filled. OK. 

    In that case, what is a Stroke, the constant-width lines that the B tool draws? (Are strokes alien to Inkscape, perhaps only added late as imports from foreign packages?) They are obviously important for CAD-like applications, and for cutting lines in art for jigsaws, CNC and laser cutters, but they are also useful for regular pen art drawings like I do. A lot of comic art uses line drawings. 

     

  13. #13
    OookLout OookLout @OookLout

    In my work I need to alter drawings which contain mostly constant-width Paths (like curved C tool pen-strokes. for example) and there doesn't seem to be an easy way to manipulate a part of those Path objects. Either I drag one as a whole, using the S command, or. with the N command I can drag individual nodes and also alter the Bezier lines between nodes. Those are both useful and powerful, of course, and I do a lot of that in my tweaking and cleanup editing.
    My problem comes when I need to bend or drag a part of a curve. With single-line curves like the B and P tools produce, it is easy to alter the line to e.g. follow an underlying bitmap layer. But with Paths, I have to alter the nodes on both sides of the curve individually, to keep the filled width constant, which is of course twice the work (or more).

    Summary:
    As I stated at the top of this thread, I draw line drawings on a Wacom Intuos Pad, and the exported SVG output is all filled paths. If I could press one button and have all these paths thin to a single line following the original line's centrelines, I would be very happy and could more quickly tweak and clean up the drawing; finally pressing Path/Stroke to Path to get adjustable-width lines where I needed them (not many).    

  14. #14
    Tyler Durden Tyler Durden @TylerDurden
    OookLout

    In that case, what is a Stroke, the constant-width lines that the B tool draws?

    Strokes are style properties applied to path/shape outlines. This is consistent across illustration tools, and mostly analogous to lineweight in drawing/drafting tools.

     

    OookLout

    with the N command I can drag individual nodes and also alter the Bezier lines between nodes. ...  My problem comes when I need to bend or drag a part of a curve.

     

    I presume you are familiar with dragging directly on a segment between nodes. For new users, this can be overlooked.

     

     

  15. #15
    OookLout OookLout @OookLout
    *

    Hi Tyler
    Yes I know about the N node tool drag etc you show there. (Your demo is great - is there a note somewhere on howto make/post such demos?).
    There is definitely a communication problem here, I know I didn't quite understand Inkscape's use of the terms Path and Stroke, but let's use your demo example. You draw a series of single-line straight-line segments, finally closing the loop behind the rabbit's ear. You then modify the bezier curves and line thickness, OK. 

    Let me try to explain what I am trying to find a fix for. Imagine that you highlight your whole initial straight-line rabbit outline shape and do Path/Shape to Path. The rabbit outline is now a dual-line Filled Path (as I'll call it) and that is the line-form that all the shapes in my imported drawings have. Now when you try to modify all your now-dualled straight-line Beziers, say to follow the rabbit image better, you will have at least double the work, as there are two unconnected lines to adjust where you used to have just one. Add in the behaviour where moving a node tends to unpredictably explode its curve into a big loop which needs fixing, and you will see that it is a tough job.

    One solution to reduce the Filled Path to a single line would be to manually delete the inner or outer loop (all my imported lines have constant 0.265mm width), but I would need to do that semi-automatically for a large selection (my drawings have hundreds of lines). Hence my quest for a single-line centre-line rendering of a 'filled path'.

    Hope that makes it clearer. If I wasn't so busy fixing these lines I would draw an example but how to upload an image?  I don't see an image upload icon in this forum text editor?.
      
    I just noticed that Inkscape has an Inkspace, is that the place to upload examples to link to in forum posts?

    (Not to be confused with Wacom's Inkspace which is their application to capture pen drawings made on their tablets, and whose SVG exports are the cause of my troubles!!).

  16. #16
    Tyler Durden Tyler Durden @TylerDurden

    OK... I'm getting clearer on this... it helps when I read more carefully.  I was skimming over the use of an app to sketch/trace, not using a tablet as an input device.

    I totally agree that a magic button that converts a closed path to a stroked path would be awesome. The bitmap>centerline trace is as close as we might get.

    The path-inset steps can be adjusted smaller/larger in the preferences, if that is helpful... but the effect on nested compound paths may be unpredictable.

    The tweak tool can be used to push pairs of paths around... it may be fiddly and make some paths lumpy.

     

     

    I poked around the Wacom site and that lead me to the WILL format, which lead me to this:

     

    "Although the Wacom app (Incspace) exports to SVG format, it represents the strokes as closed polygons. If you, for example, draw a straight line in the tablet, the SVG won't have a single path line, but instead a closed shape with the width of the stroke strength that you used to draw the line.

    For several applications, what matters is the path traced by the pen and the strokes widths along that path. That information IS present in the WILL file but, as mentioned before, not in the exported SVG. Hence, this program reads the WILL file and save an SVG with each path as each stroke given in the tablet."

    https://github.com/ngmsoftware/will2svg

    Of course, Will2Svg won't be useful on drawings already exported. Maybe a combination of the techniques mentioned above will be useful. Depending on the complexity of the drawings, if the data is still available in the WILL format, a re-export/start-over is the path of least resistance.

     

    I record and screen-clip in Windows using ShareX (foss) and attach png, gif or mp4 depending on the content. I use Autohotkey  (foss) for click and key overlays.

     

     

  17. #17
    OookLout OookLout @OookLout

    Well Done man. That is exactly the problem I have and maybe I can get that workflow going. (My existing drawings are all done thankfully!)

    I just made a picture of my problem and have a screenshot but how do I paste it into this forum post? It would maybe help others to understand what we have been arm-wrestling over during these months :-) 

  18. #18
    Tyler Durden Tyler Durden @TylerDurden
    👍

    To attach a file to a reply, click the paperclip icon below the text composition area. 👍

  19. #19
    OookLout OookLout @OookLout

    This diagram shows the issue I am facing. Hoping to solve it by Python pre-processing the output of the Intuos tablet in WILL file format so that all the imported lines will be open, single paths. Perhaps I will just have to draw better on the tablet so that I need to make less adjustments after importing to Inkspace? LOL  

    Screenshot 2021 10 18 153825
  20. #20
    Polygon Polygon @Polygon🌶

    I find it strange the Wacom produces these color filled shapes by default - this just makes sense for dynamic strokes with different widths controlled by either the tablet driver, OS or software used. I´m pretty sure this can be disabled somewhere.

  21. #21
    OookLout OookLout @OookLout

    These filled paths are produced by the Wacom 'Inkspace'[sic] app's svg export option. Their internals have a ton of simple path, pen-angle and pressure data, but the svg exporter interprets this into a filled path of default 0.265mm wide. The surrounding loop path is not coloured(no svg stroke paint).  The WILL file format apparently exports the simple path data we need but it needs converting to svg - hence the python prog referred to above:

     https://github.com/ngmsoftware/will2svg

    I will look at it asap, although I have an art deadline which will have to be met by tweaking my drawings manually for now! 

     

  22. #22
    OookLout OookLout @OookLout
    *

    Of course I haven't made it clear, I am using the Intuos Paper function, drawing live onto A4 paper clipped to the tablet (not even plugged into the PC), and then later the Wacom app loads the drawings into the PC when I connect the USB port. I guess the app loads fully detailed data, maybe using WILL format but it's all proprietary, inside the USB).

    HOWEVER - The Wacom 'Inkspace' app can not export in WILL format it seems. Maybe data is in WILL format among the Wacom program files on disk, but I suspect it might all be in the Wacom Cloud. They support export in 3 bitmap image formats, SVG, a couple of txt and doc formats from OCR of handwriting, and a gimmicky video showing the drawing being made in stop-frame. So the Python option looks tricky!


    I often iterate a few times, printing out drawings or parts at different scales to redraw or add detail. It all works well, best of both worlds, except this issue with the SVG filled paths exported from Wacom. 

    Another solution would be to retrain my hand to draw on-screen using the tablet live in Inkscape. Well, that's easier said than done. I think I would be quickest to learn that process using my left hand, as it wouldn't have to unlearn the last 65 years of right-handed drawing on paper!.  

            

  23. #23
    OookLout OookLout @OookLout
    👍

    I reproduce below an email from Wacom which might indicate light at the end of the tunnel... next year, sometime, never we might get a single-line-stroke SVG out of a Wacom tablet.

    FROM: Alexandra (Wacom) 
    Nov 4, 2021, 1:25 AM PDT 

    Dear Simon​, 
    Thank you for contacting Wacom Customer Support.
    Our agent, Oleksandr​, has forwarded this case to me following the feedback that you have kindly provided regarding our Inkspace App.
    I do understand the need that some of our customers, such as yourself, have to be able to export a more simplified version of a vector drawing. Your reasoning is also very detailed and clear, as to why an Inkspace SVG export function would make the process easier.
    This is this type of feedback that helps us to improve our tools and to keep our Customer Experience at the forefront of our business.
    I do thank you very much for such a constructive critic and I will ensure that your feedback will reach the relevant department. 

     

  24. #24
    BelowZeroCelcius BelowZeroCelcius @BelowZeroCelcius

    Hi @OookLout 

    Did you get the solution to this issue? I have similar issue but I am not using Wacom. I just copy SVG line arts to PowerPoint and everything is a line made of filled shapes. I would like to know if I can get the SVG converted to lines somehow.

    Thanks, 

  25. #25
    vergevaliant19 vergevaliant19 @vergevaliant19

    I needed to correct many tiny open and overlapping paths on a slightly complex and high path count shape. Here's a more automated approach with built in tools:

    1. paint bucket new paths into the shape

    2. union these new paths

    3. convert the paths to bitmap

    4. trace bitmap brightness cutoff

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Is there a Path to Stroke function?