Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masks do not work #24

Open
loderer opened this issue Dec 9, 2019 · 1 comment
Open

Masks do not work #24

loderer opened this issue Dec 9, 2019 · 1 comment

Comments

@loderer
Copy link

loderer commented Dec 9, 2019

The following svg is an example on how to use masks, taken from mozilla.org:

<svg viewBox="-10 -10 120 120">
  <mask id="myMask">
    <!-- Everything under a white pixel will be visible -->
    <rect x="0" y="0" width="100" height="100" fill="white" />
    <!-- Everything under a black pixel will be invisible -->
    <path d="M10,35 A20,20,0,0,1,50,35 A20,20,0,0,1,90,35 Q90,65,50,95 Q10,65,10,35 Z" fill="black" />
  </mask>
  <polygon points="-10,110 110,110 110,-10" fill="orange" />
  <!-- with this mask applied, we "punch" a heart shape hole into the circle -->
  <circle cx="50" cy="50" r="50" mask="url(#myMask)" />
</svg>

The rendered svg looks like this:
grafik

After converting it to jpeg, the result looks like this:
grafik

To convert the svg i used the following command:

svg2img(svgString, {format:'jpg','height':500,'width':500}, function(error, buffer) {
    //default jpeg quality is 75
    fs.writeFileSync('foo5.jpg', buffer);
});

If i use the same code to convert a svg without a mask, it works fine.
Am I doing something wrong, or is it actually a bug?

@fuzhenn
Copy link
Owner

fuzhenn commented Jun 11, 2020

I thinks it's a bug due to the upsteam canvg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants