Hi everyone,
I have an image with white or transparent parts inside. What I want to achieve is to fill it with another image. That can happen multiple times because my image is a container of products and I need to merge these image with imagemagick
Do I need to compute the position then layer both images or is there a simplier way to do this ?
Thanks !
Fill transparent/white with an image
Re: Fill transparent/white with an image
So I did work on this subject and now I really know what I want to do
I try to get the white part of my image and I try to use connected-components
I did the following command :
convert t_container_1.png -threshold 10% -define connected-components:verbose=true -connected-components 8 test_connected.png
But the result is this :
Objects (id: bounding-box centroid area mean-color):
0: 2655x1009+0+0 1327.0,504.0 2678895 srgba(255,255,255,1.02446)
I need 3 shape with x and y positions to layer another image inside it
Any help why this command doesn't return the 3 white shapes of my image ?
EDIT
To help you here is a screenshot of what I try to do
https://imgur.com/3ngLvHU
I need to detect the 3 white shapes then add other images to fill them
I try to get the white part of my image and I try to use connected-components
I did the following command :
convert t_container_1.png -threshold 10% -define connected-components:verbose=true -connected-components 8 test_connected.png
But the result is this :
Objects (id: bounding-box centroid area mean-color):
0: 2655x1009+0+0 1327.0,504.0 2678895 srgba(255,255,255,1.02446)
I need 3 shape with x and y positions to layer another image inside it
Any help why this command doesn't return the 3 white shapes of my image ?
EDIT
To help you here is a screenshot of what I try to do
https://imgur.com/3ngLvHU
I need to detect the 3 white shapes then add other images to fill them
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Fill transparent/white with an image
What version of IM? On what platform?
I don't understand your problem. Please show sample images.
I don't understand your problem. Please show sample images.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fill transparent/white with an image
Please provide actual input images, not screenshots. Then explain exactly what you want to get for a result.
Re: Fill transparent/white with an image
Version: Version: ImageMagick 7.0.8-34 Q16
Platform: Mac os x
Input image:
1. https://imgur.com/0N1fuAl
I want to get the positions of the 3 holes in the first image.
After getting positions I will fill it with another image
Thanks for your time, I hope it's ok now
Platform: Mac os x
Input image:
1. https://imgur.com/0N1fuAl
I want to get the positions of the 3 holes in the first image.
After getting positions I will fill it with another image
Thanks for your time, I hope it's ok now
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Fill transparent/white with an image
Code: Select all
magick 0N1fuAl.png +repage -background Black -layers Flatten -alpha off -channel RGB -threshold 10% +threshold -define connected-components:verbose=true -define connected-components:area-threshold=10000 -connected-components 8 x.png
Objects (id: bounding-box centroid area mean-color):
1: 1328x505+0+0 664.0,252.4 358174 srgb(255,255,255)
17: 328x328+914+89 1077.5,253.0 104487 srgb(0,0,0)
16: 328x328+498+88 661.6,251.4 104143 srgb(0,0,0)
10: 326x329+84+86 246.9,250.2 103836 srgb(0,0,0)
snibgo's IM pages: im.snibgo.com
Re: Fill transparent/white with an image
Thanks man