How do you fill the image within other image's boundaries?

Areg

Hi guys i am trying to fill an image inside a png outline like this

enter image description here

Currently what i have

<img _ngcontent-udx-c1="" alt="content-icon" src="https://i.stack.imgur.com/ob90p.png" ng-reflect-ng-style="[object Object]" style="background: url(&quot;https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/nature-quotes-1557340276.jpg&quot;);">

where the event-icon.png is the white outline and the background is some random image from google. And the result is enter image description here

But i want it do fill inside the other image's boundaries instead of just pushing it out through the entire tag. How can i achieve this?

Temani Afif

You need to create another image like below and use it as mask:

body {
  background:lightblue;
}
<img src="https://i.ibb.co/RyJRkpB/mask.png" />
<img src="https://i.stack.imgur.com/ob90p.png" />

In the above we have both images, the mask and the one with outline and you get the following if you combine them:

.box {
  -webkit-mask:url(https://i.ibb.co/RyJRkpB/mask.png) center/contain no-repeat;
          mask:url(https://i.ibb.co/RyJRkpB/mask.png) center/contain no-repeat;
  background:url(https://picsum.photos/id/1014/800/800) center/cover;
}

body {
  background:lightblue;
}
<img src="https://i.stack.imgur.com/ob90p.png" class="box">

The result isn't perfect because I am bad at image editing but you can easily edit the mask image to make it better

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do you stretch an image to fill a <div> while keeping the image's aspect-ratio?

How do I keep a draggable image within the rectangle boundaries of another image in Kivy?

Overlay/Fill country boundaries with image in

How to merge an image to fill in other image with shape?

How do you triangulate the location of a pixel in an image using it's location in other images?

How to bounce an image between the boundaries

How to detect the boundaries of records in an image?

How do you change an IBAction UIButton's image in Swift?

How do you display an image from s3 on a website?

How do you stretch a background image's width?

how do you handle a double image file when it`s edited

How to get an image as the SVG fill's background

How to fill segmented area within a mask in image segmentation task?

How to have image fill remaining space within a div?

How do you reference dockerhub as a source for your application image within the codedeploy appspec?

How do you add an image to the corner of page without interfering with other elements?

Wrap lines of text within image boundaries using gd

POSIX: How do you determine your own process's file image so you can exec yourself?

how to fill a image with pattern

How to "fill" background image?

How to fill a polygon with an image?

How to fill Path with Image?

How do you load an external image with SDWebImage?

How do you binarize a colored image?

How do you translate an image with Symfony and Twig

How do you change the transparency of an image in OpenCV?

How do you add dependency to a Pharo image?

How do you cache an image in Javascript

How do you crop an image in iOS