Page 1 of 1
composite flag with image
Posted: 2014-11-29T03:41:59-07:00
by mostafanastary
Hi,
I need to composite flag on face for create football fans.
I have some flag and when in use :
exec("convert face.jpg flag.jpg -compose Overlay -composite -quality 100 ".$result_image);
the result picture is not good in every case, for example if the flag has some color or shap result is better but with solid color, no.
in fact i need to create some picture like:
http://photofunia.com/categories/lab/football_fan
can you help me please?
( sorry for my bad en

Re: composite flag with image
Posted: 2014-11-29T12:31:13-07:00
by fmw42
Upload your two input and output images to some free hosting service such as dropbox.com and put the URLs here. Then explain what is bad about the output result. Perhaps you need a different compose method.
Re: composite flag with image
Posted: 2014-11-29T13:40:25-07:00
by mostafanastary
Hi again,
thank for reply
with png file and 50% transparency with photoshop and use the:
exec("composite multiply -gravity center -geometry +0+0 iran.png face.jpg -quality 100 result.jpg");
result is:
http://i59.tinypic.com/2jbw7jr.jpg
and with 100% transparency flag like:
http://i57.tinypic.com/2wqedyg.jpg
My result is:
http://i59.tinypic.com/10gcl6s.jpg
and photofunia is:
http://i58.tinypic.com/2d7xy7b.jpg
i use :
exec("convert face.jpg iran2.png -compose Overlay -composite -quality 100 result.jpg"); //Overlay
As you see, in my result with png and 50% transparency, i have a bad result, in case 2 and use the Overlay blend mode like photoshop my result is better but in photofunia result, the lips and face shown and red,white and green color is true and good for best result.
Re: composite flag with image
Posted: 2014-11-29T15:32:46-07:00
by fmw42
I need to have your two input images, so I can test myself. Also what version of IM are you using and what platform?
Re: composite flag with image
Posted: 2014-11-30T04:41:56-07:00
by mostafanastary
Re: composite flag with image
Posted: 2014-11-30T13:46:28-07:00
by fmw42
try one of these and let us know if one of them is what you want. The first image is the face and the second in parens is the flag.
Code: Select all
convert FUfstEv.jpg \( ChYNTch.jpg -alpha set -channel a -evaluate set 50% +channel \) \
-gravity center -compose over -composite result1.jpg
Code: Select all
convert FUfstEv.jpg \( ChYNTch.jpg -alpha set -channel a -evaluate set 50% +channel \) \
-gravity center -compose overlay -composite result2.jpg
Re: composite flag with image
Posted: 2014-11-30T15:11:19-07:00
by mostafanastary
Dear fred,
your code is good, but with my face picture in photofunia.com result is very real, why?

Re: composite flag with image
Posted: 2014-11-30T17:18:24-07:00
by fmw42
They have either a mask to cut the image to the face shape and/or they have code to wrap the image texture onto the face. Sorry I cannot tell which it is. But the first thing would be to make a mask for the area of the face you want and use the mask. The mask should be antialiased around its edges so that it blends at the edges. The mask image would then be a third image placed just before -compose in the code above.
See masked blending at
http://www.imagemagick.org/Usage/compose/#compose
Here is an example:
#mask was processing in a GIMP or Photoshop to draw a polygon about the face, then blurred (-blur 0x3) in ImageMagick
convert FUfstEv.jpg \( ChYNTch.jpg -resize 220% -alpha set -channel a -evaluate set 50% +channel \) \
-gravity center -geometry +0-30 mask4.png -compose over -composite result3.jpg

Re: composite flag with image
Posted: 2014-11-30T17:28:03-07:00
by mostafanastary
Oh Yes,
I think about it and your answer is the best for me.
thank you so much.
Re: composite flag with image
Posted: 2014-11-30T18:01:20-07:00
by mostafanastary
wow, it's true, thank you fred, you are good person.
Re: composite flag with image
Posted: 2014-11-30T18:29:01-07:00
by mostafanastary
Hi again fred,
with your trick i use brush in photoshop and create two eyes for mask:
then composite it with another picture, the result is very good:
but color of the flag is not real yet.
thank you again .
Re: composite flag with image
Posted: 2014-11-30T20:06:28-07:00
by fmw42
try changing the 50% to 65%
Re: composite flag with image
Posted: 2014-12-01T02:50:24-07:00
by mostafanastary
Ok,
the result is very good,
i try to add some texture as you told to my flag color with photoshop with overlay blend mode and is seem awesome.
thank you fred for your help.
best regards.