I was messing around with SVG Masks and after reading a few articles and testing some codes for a fancier mask, more than just simple polygons, I came up with this:
<div class="picture">
<img src="https://i.postimg.cc/0Njq2C60/bartrix.png"
alt="" style="clip-path: url(#myClip)">
</div>
<svg width="0" height="0">
<defs>
<clipPath id="myClip">
<path id="blob" fill="none"
d="M351,264.5Q338,279,387.5,332.5Q437,386,400.5,396Q364,406,324,380.5Q284,355,267,420Q250,485,225.5,443Q201,401,158,418.5Q115,436,82,416Q49,396,112.5,335Q176,274,100,262Q24,250,75,230Q126,210,100,166Q74,122,135.5,150Q197,178,197.5,134Q198,90,224,60Q250,30,275.5,62Q301,94,314.5,118.5Q328,143,348,153.5Q368,164,397.5,178Q427,192,395.5,221Q364,250,351,264.5Z" />
</clipPath>
</defs>
</svg>
Looks very nice, but I stumbled on two problems:
- As you can see the image used in this test is not quite well positioned within the visible part of the mask. Therefore I would like to know if it's possible to reposition it
- It's huge! Because I'm not very well versed with SVG, I couldn't resize it as the usual properties does nothing on the parent (
.picture
), in the SVG itself and, if applied to the image instead, it vanishes. Re-scale it withtransform
, works, though, but I highly doubt this is the right way to do it.
So, in summary, how could I mask any image, adjusting it within this mask without editing the images themselves (which would be the most desirable - a code that works for images instead of images that works for a code, if you know what I mean).
If, by any chance, any other mask can be used, would be even better. This shape was one of the best I could find but I have a few others to test too.