Composite over another image
Composite over another image
I want to display some of photos inside the lens.
I can do this in photoshop. But i am not able to find a proper way to do this in imagemagick.
Please tell me how to do
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composite over another image
Make the inside of the lens (where it is white) into transparent. Then resize and crop your other image to the same size as this one. Or extend it if small to the same size as this one. Then composite them. Below is Unix syntax. Remove the \ before the parens and escape the ^ as ^^ for Windows syntax (I think that is correct).
or
Code: Select all
convert lens.jpg -fuzz 5% -fill none -draw "matte 50,50 floodfill" magnifier.png
Code: Select all
convert rose: -resize 180x180! rose.png
Code: Select all
convert rose.png magnifier.png -compose over -composite result.png
or
Code: Select all
convert -size 180x180 xc:black \( rose: -resize 90x90^ \) -compose over -composite rose2.png
Code: Select all
convert rose2.png magnifier.png -compose over -composite result2.png
Re: Composite over another image
Sir, The magnifier is completely transparent image. There is a group photo. I want to apply this magnifier on that photo. so it is completely transparent. Can we just find and replace the white place in this magnifier with another image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composite over another image
That is what I have done in the result.png images. I made the circle of the magnifier transparent. Then I put the rose image behind this image so that is shows inside the magnifier circle.agriz wrote:Can we just find and replace the white place in this magnifier with another image?
Perhaps I do not understand your problem. You need to have a transparent circle in the white area of the magnifier so that another image will show behind it.
Please post your other image that you want to show in the magnifier. And explain further what you want to do with that image in relation to the magnifier.
Note: the concept is not to cut out a circle image and place it over the white area of the magnifier. It is to cut out (make transparent) the white area in the magnifier, so that it allows a background image to show within the transparent region. It can be done this other way, but it is a little more complicated.
Code: Select all
convert lens.jpg rose2.png \( magnifier.png -alpha extract -negate \) -compose over -composite result3.png
Re: Composite over another image
This is the right image. The magnifier became jpg and lost the transparency
Re: Composite over another image
Sir,
By using the above code i changed my room pic to round shape and composite the rounded room to magnifier.
But i am not sure how the code shapes the picture round and circle's first two parameters are understandable and the last two are confusing.
Can you please explain me the above code?
I will be very thankful for you.
Thanks
Code: Select all
exec($im."\convert my_room.jpg -resize x115 ( +clone -threshold -1 -negate -fill white -draw \"circle 55,55 55,0\" ) -alpha off -compose copy_opacity -composite my_room_mini.png");
But i am not sure how the code shapes the picture round and circle's first two parameters are understandable and the last two are confusing.
Can you please explain me the above code?
I will be very thankful for you.
Thanks
Re: Composite over another image
55,55 is the centre of the circle and the 55,0 is a point on the circumference which sets the diameter.
Re: Composite over another image
Code: Select all
-resize x115
Code: Select all
-resize x110
Re: Composite over another image
Code: Select all
convert my_room.jpg -resize x115 ( +clone -threshold -1 -negate -fill white -draw \"circle 55,55 55,0\" ) -alpha off -compose copy_opacity -composite my_room_mini.png
convert my_family_photo.jpg my_room_mini.png -geometry +0+0 -composite family_room.jpg
How can i combine these two convert commands?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composite over another image
If the two separate commands work, then try
If that does not work, then post your two input images and the working output image, so we can test properly on your images to see what is happening.
Code: Select all
convert my_room.jpg -resize x115 ^
( +clone -threshold -1 -negate -fill white -draw \"circle 55,55 55,0\" ) ^
-alpha off -compose copy_opacity -composite ^
my_family_photo.jpg +swap -compose over -composite family_room.jpg
Re: Composite over another image
Sir, thanks for the code. i will check it out and let you know. Is there any book to study imagemagick in details?
Thanks for your help
Thanks for your help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composite over another image
see "Getting Help" at http://www.imagemagick.org/script/sitemap.php#help
But those books are rather old. I would suggest you study:
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
But those books are rather old. I would suggest you study:
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
Re: Composite over another image
Thank you sir.
Your script is working beautifully!
convert rose.jpg -resize 109x109^ -gravity center -extent 109x109 -crop 109x109+0+0 rose_cropped.png
convert maginfier.png rose_cropped.png -geometry +10+10 -compose DstOver -composite magifier_rose.png
How can we use -alpha to remove the visible edges of rose from the magnifier?
Your script is working beautifully!
convert rose.jpg -resize 109x109^ -gravity center -extent 109x109 -crop 109x109+0+0 rose_cropped.png
convert maginfier.png rose_cropped.png -geometry +10+10 -compose DstOver -composite magifier_rose.png
How can we use -alpha to remove the visible edges of rose from the magnifier?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Composite over another image
try this, where lens.jpg is your original opaque magnifier image.
Code: Select all
convert lens.jpg -fuzz 5% -fill none -draw "matte 50,50 floodfill" \
-alpha extract -blur 0x1 -level 50x100% mask_inner.png
color=`convert lens.jpg -format "%[pixel:u.p{0,0}]" info:`
convert lens.jpg \
\( -clone 0 -bordercolor "$color" -border 5 -fuzz 5% -fill none \
-draw "matte 0,0 floodfill" -alpha extract -shave 5x5 -blur 0x1 -level 0x50% \) \
-alpha off -compose copy_opacity -composite lens_outer.png
convert rose.jpg -resize 109x109^ -gravity center -extent 109x109 -crop 109x109+0+0 rose_cropped.png
convert rose_cropped.png \( mask_inner.png -negate \) -alpha off -compose copy_opacity -composite rose_cropped_trans.png
convert lens_outer.png rose_cropped_trans.png -compose over -composite x: