composite flag with image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

composite flag with image

Post 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 :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite flag with image

Post 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.
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite flag with image

Post 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?
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post by mostafanastary »

Hi fred,

i need use every face and every flag with any color, like:

http://i.imgur.com/pduoc2Y.jpg
http://i.imgur.com/pt3pTa4.jpg
http://i.imgur.com/FUfstEv.jpg
http://i.imgur.com/ChYNTch.jpg

thank you
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite flag with image

Post 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
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post by mostafanastary »

Dear fred,

your code is good, but with my face picture in photofunia.com result is very real, why?

Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite flag with image

Post 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
Image

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

Image
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post by mostafanastary »

Oh Yes,
I think about it and your answer is the best for me.

thank you so much.
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post by mostafanastary »

wow, it's true, thank you fred, you are good person.
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post by mostafanastary »

Hi again fred,
with your trick i use brush in photoshop and create two eyes for mask:

Image

then composite it with another picture, the result is very good:

Image

but color of the flag is not real yet.

thank you again .
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite flag with image

Post by fmw42 »

try changing the 50% to 65%
mostafanastary
Posts: 44
Joined: 2014-11-28T16:19:41-07:00
Authentication code: 6789

Re: composite flag with image

Post 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.
Post Reply