I need to mask an image using an SVG element. I have a very detailed inline SVG element on my page that I would like to use as a mask for the image to be uploaded. My SVG is drawn using <path>
. I would like something similar to this example http://jsfiddle.net/pjgalbraith/cnLHE/ . * I notice that this example does not work in Chrome or IE9 for me, but only FF.
This is my main structure.
<div> <svg width="500" height="500"> <mask id="myMask'> <g> <path/> </g> </mask> </svg> <img src="http://myImage.jpg" style="mask:url(#myMask);"> </div>
I tried adding the <mask>
inside the SVG, which wraps the group <g>
, which does not work.
This makes my SVG graphics completely transparent, therefore, I assume that it is trying to work, and SVG acts like a mask, but the image is not masked at all, it just overlays the position. Does <img>
need to be inside <svg>
or something like that?
Does anyone have SVG experience and will know how to do this? Every example I see uses simple rectangular or svg graphics to mask, but there are no paths. Maybe why? Thanks
source share