using image as mask

Discuss SVG code, accessible via the XML Editor.
jecede

using image as mask

Postby jecede » Sat Jan 09, 2010 2:29 am

Is it possible to use a black and white png/jpg/whatever as a mask for an image? All the masking filters are using rectangles
something like
<image ...bla bla mask="mask.png"/>

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: using image as mask

Postby sas » Sat Jan 09, 2010 3:15 am

You can only mask with a mask element. So you would do something like

Code: Select all

<mask id="mask1">
  <image xlink:href="mask.png" x="50" y="50" width="200" height="200"/>
</mask>

and apply it with mask="url(#mask1)".

jecede

Re: using image as mask

Postby jecede » Sat Jan 09, 2010 4:01 am

thanx! super, it works just like you said.
you made my day.


Return to “SVG / XML Code”