Inkscape.org
Creating New Extensions Donating a program for svg diagnostics
  1. #1
    OptimusPrime OptimusPrime @OptimusPrime

    Dear Devs,

    I couldn't run a boolean operation extension on a path group and investigated. Finding the error took too long, so I wrote a python based standalone .exe to investigate and log svg XML corruption and critical definition malforming. It can bypass UTF-8 corruption and log it. It identifies and skips raw image data of enbedded images and node data of paths. A full run on a 15Mb file takes 2-3 seconds. I wrote and tested it in the PyCharm SDK, but that is not needed to just run it. I believe it might be of value and offer it to your cause, alongside the source code. In exchange, I demand a life-time long free right-of-use for all of inkscape.

    Best Regards, and thanks for Inkscape

    Optimus

  2. #2
    Polygon Polygon @Polygon🌶

    You might want to provide your effort here: https://chat.inkscape.org/channel/team_devel

    because devs are not usually lurking here around.

  3. #3
    OptimusPrime OptimusPrime @OptimusPrime

    Hi, thanks a lot! I'll give it a try :)

  4. #4
    Maren Hachmann Maren Hachmann @Moini

    I don't understand - does this fix (my) extension or does this fix Inkscape?

  5. #5
    Maren Hachmann Maren Hachmann @Moini

    And why wasn't this reported to the extension issue tracker?...

  6. #6
    OptimusPrime OptimusPrime @OptimusPrime
    *

    It doesn't repair anything. All repair has to be done manually. But it tells you what needs repairing. If you have corruption in an attribute descritption, like a linear gradient, it will list that graident as corrupted. It will also list any path objects that use broken attributes. You would use the result to remove defunct symbols or attributes in the svg via Notepad. You can then, in Inkscape, search for "Path 117" or so in the xml viewer and re-assign a working gradient. The program can be refined by a learned programmer who knows XML structure and inkscape characteristics better than me. But it will work in a variety of instances.

    Reported where? I'm a user, not a dev.

  7. #7
    Maren Hachmann Maren Hachmann @Moini

    So, what exactly was the problem you encountered with (likely) https://gitlab.com/moini_ink/inx-pathops? (if it was that one - but in any way, please report the problem to the repository where you got the extension from).

  8. #8
    OptimusPrime OptimusPrime @OptimusPrime
    *

    Looks like the one to do Boolean ops on multiple paths in a group at once. I think that's it.. Thing is: I don't even understand what i see on those GitHub pages. Like, they confuse the hell outta me. Most of the time i dont even understand where i am and how to DL stuff. Not sure i wanna do tec discussion on GH. Nah sorry i don't trust GH. I checked and won't create an account there atm.

    I'll provide the example svg and a log tho. The critical issue was in line 89, it reads (corrupt characters not printable):

       message="  " /> &quot; /&gt;<linearGradient
     

    Traceback (most recent call last):
      File "C:\Users\Björn\AppData\Roaming\inkscape\extensions\org.inkscape.extension.11098\pathops.py", line 477, in <module>
        PathOps().run()
      File "C:\Program Files\Inkscape 3.2\share\inkscape\extensions\inkex\base.py", line 249, in run
        self.load_raw()
      File "C:\Program Files\Inkscape 3.2\share\inkscape\extensions\inkex\base.py", line 263, in load_raw
        document = self.load(self.file_io)
                   ^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Program Files\Inkscape 3.2\share\inkscape\extensions\inkex\base.py", line 496, in load
        document = load_svg(stream)
                   ^^^^^^^^^^^^^^^^
      File "C:\Program Files\Inkscape 3.2\share\inkscape\extensions\inkex\elements\_parser.py", line 98, in load_svg
        parsed = etree.parse(stream, parser=SVG_PARSER)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "src/lxml/etree.pyx", line 3541, in lxml.etree.parse
      File "src/lxml/parser.pxi", line 1900, in lxml.etree._parseDocument
      File "src/lxml/parser.pxi", line 1920, in lxml.etree._parseFilelikeDocument
      File "src/lxml/parser.pxi", line 1814, in lxml.etree._parseDocFromFilelike
      File "src/lxml/parser.pxi", line 1204, in lxml.etree._BaseParser._parseDocFromFilelike
      File "src/lxml/parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
      File "src/lxml/parser.pxi", line 728, in lxml.etree._handleParseResult
      File "src/lxml/parser.pxi", line 657, in lxml.etree._raiseParseError
      File "C:\Users\BJRN~1\AppData\Local\Temp\ink_ext_XXXXXX.svg4JZJV2", line 89
    lxml.etree.XMLSyntaxError: Input is not proper UTF-8, indicate encoding !
    Bytes: 0x90 0xE1 0x7F 0x22, line 89, column 13
    

    I deleted the line but had to reassign a gradient afterwards. That's what I wrote my program for, to find where exactly i need to reassign. To replicate, try to perform 'Difference' on the gray-scale group [hand] (not the shading objects above it) with the outline white field bottom left at the wrist as cutting path. Hope that helps.

    Screenshot 2024 10 05 202204
  9. #9
    OptimusPrime OptimusPrime @OptimusPrime
    *

    Edited above post.

    Edit 2: Ain't nothing wrong with your extension. This is about corruption in the svg itself and how to handle it. How it gets there...no idea.

    And by the way: Thank you very much for your extension. Had a feeling i knew the name.  It allowed me to get a work of passion to a whole new level :)

  10. #10
    Maren Hachmann Maren Hachmann @Moini

    Yeah, indeed. The webbrowser already says where the error is - it does XML validation, too. 

    And the file was broken when it fell out of Inkscape? Or how did that piece of text get into the file?

    You're welcome. It's GitLab, though, not GitHub.

    At first, I thought the file name sounded like something medical/orthopedic, but it looks more like it's about making knight's armor....

     

  11. #11
    OptimusPrime OptimusPrime @OptimusPrime

    Hi Maren, I'm sorry it took so long. First: I was flattered! Yes indeed, it is a making-of of a piece of articulated armor, one of many that I'm doing. I'm surprised you figured that out in this early state.

    About the webbrowser - I do not even know where that message came from. I'm glad my issue can be reproduced, but...what webbrowser? Firefox? Even then, that shows the problem i had - i knew where the error was, but not what it did affect. My program above is designed to find instances of paths that use corrupt attributes so i don't have to search my drawing for items using a bad gradient.

    I'm not sure when the corruption arose, or how. It's just there and I'm confident this will happen a lot, most of the time unnoticed, due to damage on the hardware or unclean editing and saving processes when working the .svg's. I'm sorry i can't be of more help. I can not determine if the earlier run i did with your extension caused the issue, but i doubt it. Many instances of corruption can be found throughout my files in places that wouldn't have been touched by your extension.

    Have a good weekend! Björn

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Donating a program for svg diagnostics