title: Apply a texture to an image in SVG
body: <p>I'm trying to apply a texture to an image  </p>
  
  <p><strong>Original</strong></p>
  
  <p><a href="https://i.stack.imgur.com/mApRC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mApRC.png" alt="enter image description here"></a></p>
  
  <p><strong>Texture</strong></p>
  
  <p><a href="https://i.stack.imgur.com/hwmkT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hwmkT.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Result</strong> (made with PHP GD)</p>
  
  <p><a href="https://i.stack.imgur.com/w3EZG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w3EZG.png" alt="enter image description here"></a></p>
  
  <p>But with SVG, the closest I got is this result</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;svg preserveAspectRatio="none" width="500" height="500" viewBox="0 0 500 500"&gt;
      &lt;defs&gt;
      
        &lt;filter id="texture"&gt;
          &lt;feImage href="https://i.imgur.com/pjWcnJs.jpg" result="texture-img"/&gt;
          &lt;feBlend in="SourceGraphic" in2="texture-img" mode="multiply"/&gt;
        &lt;/filter&gt;
      
      &lt;/defs&gt;
      
      &lt;g&gt;
          &lt;g filter="url(#texture)"&gt;
              &lt;image x="0" y="0" href="https://i.imgur.com/oVEdsQt.png" opacity="1" width="500" height="500" /&gt;
          &lt;/g&gt;
      &lt;/g&gt;
      
  &lt;/svg&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://jsfiddle.net/unloco/168z3og2/4/" rel="nofollow noreferrer">fiddle</a></p>
  
  <p>Is there another way which won't texturize transparent pixels?</p>