GithubHelp home page GithubHelp logo

Comments (3)

liZe avatar liZe commented on June 9, 2024 1

Yes, you have to give bytes to svg2svg. Use svg = b"""… to fix that.

from cairosvg.

liZe avatar liZe commented on June 9, 2024

Thanks for the report! It should be fixed now.

from cairosvg.

erwanvivien avatar erwanvivien commented on June 9, 2024

Hey @liZe

I've tried the same code with this commit cf0c406

$ pip install git+https://github.com/Kozea/CairoSVG@cf0c40677f9349ca366bbdc878f7bf0b79768161
python
Python 3.10.6 (main, Sep 11 2023, 10:27:20) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairosvg
>>> svg = """
... <svg width="30" height="42" viewBox="0 0 30 42" fill="none" xmlns="http://www.w3.org/2000/svg">
... <g id="Group">
... <g id="pin">
... <mask id="path-1-inside-1_22_336" fill="white">
... <path d="M15 0C6.71906 0 0 6.04781 0 13.5C0 25.5 15 42 15 42C15 42 30 25.5 30 13.5C30 6.04781 23.2809 0 15 0ZM15 21C13.8133 21 12.6533 20.6481 11.6666 19.9888C10.6799 19.3295 9.91085 18.3925 9.45672 17.2961C9.0026 16.1997 8.88378 14.9933 9.11529 13.8295C9.3468 12.6656 9.91824 11.5965 10.7574 10.7574C11.5965 9.91824 12.6656 9.3468 13.8295 9.11529C14.9933 8.88378 16.1997 9.0026 17.2961 9.45672C18.3925 9.91085 19.3295 10.6799 19.9888 11.6666C20.6481 12.6533 21 13.8133 21 15C20.9983 16.5908 20.3656 18.1159 19.2407 19.2407C18.1159 20.3656 16.5908 20.9983 15 21Z"/>
... </mask>
... <path d="M15 0C6.71906 0 0 6.04781 0 13.5C0 25.5 15 42 15 42C15 42 30 25.5 30 13.5C30 6.04781 23.2809 0 15 0ZM15 21C13.8133 21 12.6533 20.6481 11.6666 19.9888C10.6799 19.3295 9.91085 18.3925 9.45672 17.2961C9.0026 16.1997 8.88378 14.9933 9.11529 13.8295C9.3468 12.6656 9.91824 11.5965 10.7574 10.7574C11.5965 9.91824 12.6656 9.3468 13.8295 9.11529C14.9933 8.88378 16.1997 9.0026 17.2961 9.45672C18.3925 9.91085 19.3295 10.6799 19.9888 11.6666C20.6481 12.6533 21 13.8133 21 15C20.9983 16.5908 20.3656 18.1159 19.2407 19.2407C18.1159 20.3656 16.5908 20.9983 15 21Z" fill="#FF8B6D" stroke="#D74F31" stroke-width="4" mask="url(#path-1-inside-1_22_336)"/>
... </g>
... </g>
... </svg>
... """
>>> 
>>> parsed_svg = cairosvg.svg2svg(svg)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/erwanvivien/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/cairosvg/__init__.py", line 41, in svg2svg
    return surface.SVGSurface.convert(
  File "/Users/erwanvivien/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/cairosvg/surface.py", line 129, in convert
    tree = Tree(
  File "/Users/erwanvivien/.asdf/installs/python/3.10.6/lib/python3.10/site-packages/cairosvg/parser.py", line 388, in __init__
    if bytestring.startswith(b'\x1f\x8b'):
TypeError: startswith first arg must be str or a tuple of str, not bytes

Do you know if I made a mistake ?

from cairosvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.