How to cut a circular part from an image?

Here is another easier way to do with SVG:

body {
  background:pink;
}
<svg width="200" height="200">
  <defs>
    <mask id="hole">
      <circle r="100" cx="100" cy="100" fill="white"/>
      <circle r="50" cx="180" cy="180" fill="black"/>
    </mask>
  <pattern id="img" patternUnits="userSpaceOnUse" width="200" height="200">
    <image  xlink:href="https://picsum.photos/200/200?image=1069" x="0" y="0" width="200" height="200" />
  </pattern>
  </defs>
  <!-- create a rect, fill it with the image and apply the above mask -->
  <rect fill="url(#img)" width="100%" height="100%" mask="url(#hole)" />
</svg>

You can also do this using CSS and mask:

body {
  background:pink;
}

img {
  border-radius:50%;
  -webkit-mask:radial-gradient(circle at calc(100% - 20px) calc(100% - 20px),transparent 50px,#fff 51px);
          mask:radial-gradient(circle at calc(100% - 20px) calc(100% - 20px),transparent 50px,#fff 51px);
  
}
<img src="https://picsum.photos/200/200?image=1069" >

Another syntax where you can easily adjust the position of the circle:

body {
  background:pink;
}

img {
  border-radius:50%;
  padding:1px;
  -webkit-mask:
    linear-gradient(#fff,#fff),
    radial-gradient(farthest-side,#fff 98%,transparent 100%) 
      bottom -30px right -30px/
      100px 100px no-repeat;
  -webkit-mask-composite:source-out;
  
  mask:
    linear-gradient(#fff,#fff),
    radial-gradient(farthest-side,#fff 98%,transparent 100%) 
      bottom -30px right -30px/
      100px 100px no-repeat;
  mask-composite:exclude;
  transition:1s;
}
img:hover {
  -webkit-mask-position:top -30px right -30px;
          mask-position:top -30px right -30px;
}
<img src="https://picsum.photos/200/200?image=1069" >

Leave a Comment