Command for merging 2 image files

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?".
satimis
Posts: 30
Joined: 2017-04-13T19:20:03-07:00
Authentication code: 1151

Re: Command for merging 2 image files

Post by satimis »

fmw42 wrote: 2017-04-30T11:48:46-07:00 - snip -

dim=`convert flag.svg -format "%[fx:min(w,h)]\n" info:`
dim2=`convert xc: -format "%[fx:$dim/2]" info:`
convert hk_central.jpg \( text_05.png -resize 80% \) \
-gravity northwest -define compose:args=80 -compose blend -composite \
\( flag.svg -gravity center -crop ${dim}x${dim}+0+0 +repage -write mpr:img +delete \) \
\( mpr:img -fill black -colorize 100 -fill white -draw "circle $dim2,$dim2 0,$dim2" \
mpr:img +swap -alpha off -compose copy_opacity -composite \) \
-gravity southeast -compose over -composite \
null: \
\( chinese-flag-waving-gif-animation-10.gif -coalesce -resize 33% \) \
-gravity northeast -geometry +20+20 -layers composite -layers Optimize \
result.gif
Thanks.

If my understanding on your syntax is incorrect please rectify me.

Code: Select all

dim2=`convert xc: -format "%[fx:$dim/2]" info:`
parameter for the 2nd further image to be added?

If I expect adding 3rd further image then the syntax

Code: Select all

dim3=`convert xc: -format "%[fx:$dim/3]" info:`
?

Code: Select all

null: \
No output. The command not finished, to be continue?

Code: Select all

-layers Optimize \
What is its function?
Why it needs Captial O?

If I retain the 2nd further image its original shape (rectangle), just leaving out;

Code: Select all

dim2=`convert xc: -format "%[fx:$dim/2]" info:`
and adjust its size to fit into the space for its adding?

Thanks

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

Re: Command for merging 2 image files

Post by fmw42 »

satimis wrote: 2017-04-30T21:22:51-07:00
fmw42 wrote: 2017-04-30T11:48:46-07:00 - snip -

dim=`convert flag.svg -format "%[fx:min(w,h)]\n" info:`
dim2=`convert xc: -format "%[fx:$dim/2]" info:`
convert hk_central.jpg \( text_05.png -resize 80% \) \
-gravity northwest -define compose:args=80 -compose blend -composite \
\( flag.svg -gravity center -crop ${dim}x${dim}+0+0 +repage -write mpr:img +delete \) \
\( mpr:img -fill black -colorize 100 -fill white -draw "circle $dim2,$dim2 0,$dim2" \
mpr:img +swap -alpha off -compose copy_opacity -composite \) \
-gravity southeast -compose over -composite \
null: \
\( chinese-flag-waving-gif-animation-10.gif -coalesce -resize 33% \) \
-gravity northeast -geometry +20+20 -layers composite -layers Optimize \
result.gif
Thanks.
satimis wrote:If my understanding on your syntax is incorrect please rectify me.

Code: Select all

dim2=`convert xc: -format "%[fx:$dim/2]" info:`
parameter for the 2nd further image to be added?
No, this is the radius of the circle
satimis wrote:If I expect adding 3rd further image then the syntax

Code: Select all

dim3=`convert xc: -format "%[fx:$dim/3]" info:`
?
No, see comment above
satimis wrote:

Code: Select all

null: \
No output. The command not finished, to be continue?
No, null: is a null image, that is used specifically in this situation to separate the first image from the animation image that you are trying to add. It is used in the -layers composite operation. See the reference I provided earlier
satimis wrote:

Code: Select all

-layers Optimize \
What is its function?
Why it needs Captial O?
It is used to optimize the animation. It does not have to be capitalized.
satimis wrote:If I retain the 2nd further image its original shape (rectangle), just leaving out;

Code: Select all

dim2=`convert xc: -format "%[fx:$dim/2]" info:`
and adjust its size to fit into the space for its adding?
No see my comments earlier about it being the circle radius.
satimis
Posts: 30
Joined: 2017-04-13T19:20:03-07:00
Authentication code: 1151

Re: Command for merging 2 image files

Post by satimis »

fmw42 wrote: 2017-04-30T11:48:46-07:00
If I expect adding further image;
chinese-flag-waving-gif-animation-10.gif
This is harder and requires special techniques to add an animation to a static image. See http://www.imagemagick.org/Usage/anim_mods/#background. And it has to be saved as GIF not PNG. Note I have reduced the size of your waving flag by 33% to make it fit without overlapping the circle.


dim=`convert flag.svg -format "%[fx:min(w,h)]\n" info:`
dim2=`convert xc: -format "%[fx:$dim/2]" info:`
convert hk_central.jpg \( text_05.png -resize 80% \) \
-gravity northwest -define compose:args=80 -compose blend -composite \
\( flag.svg -gravity center -crop ${dim}x${dim}+0+0 +repage -write mpr:img +delete \) \
\( mpr:img -fill black -colorize 100 -fill white -draw "circle $dim2,$dim2 0,$dim2" \
mpr:img +swap -alpha off -compose copy_opacity -composite \) \
-gravity southeast -compose over -composite \
null: \
\( chinese-flag-waving-gif-animation-10.gif -coalesce -resize 33% \) \
-gravity northeast -geometry +20+20 -layers composite -layers Optimize \
result.gif
Hi fmw42,

It is very strange to me. Your command here worked for me several days before seamlessly. But I just ran it again. The flag.svg on southeast became enlarged;

Please see upload file;
https://www.dropbox.com/s/ee9cun77beoma ... t.gif?dl=0

Please help. Thanks

Regards
satimis
satimis
Posts: 30
Joined: 2017-04-13T19:20:03-07:00
Authentication code: 1151

Re: Command for merging 2 image files

Post by satimis »

Hi fmw42,

I got it done. Sorry I forgot adding "-resize 40%" here

Code: Select all

mpr:img +swap -alpha off -compose copy_opacity -composite -resize 40% \) \
Please see
https://www.dropbox.com/s/mkb409f455tqn ... 4.gif?dl=0

Thanks

Regards
satimis
Post Reply