Command for merging 2 image files
Command for merging 2 image files
Hi all,
Instead of running GIMP is there a command to merge 2 images?
example:
image-1.png Text with transparent background
image-2.png For background
I expect the new page with the Text centered and image-2 as background. I have looked at;
Appending Images
http://imagemagick.org/Usage/layers/#append
and couldn't resolve which command to be used. Please help.
Thanks
Regards
satimis
Instead of running GIMP is there a command to merge 2 images?
example:
image-1.png Text with transparent background
image-2.png For background
I expect the new page with the Text centered and image-2 as background. I have looked at;
Appending Images
http://imagemagick.org/Usage/layers/#append
and couldn't resolve which command to be used. Please help.
Thanks
Regards
satimis
- 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
Please always provide your IM version and platform, since syntax may vary.
The basic concept is -compose over -composite. See http://www.imagemagick.org/Usage/compose/#compose
For IM 6
For IM 7
If these do not work, please post your images to some free hosting service such as dropbox.com and put the URLs here.
The basic concept is -compose over -composite. See http://www.imagemagick.org/Usage/compose/#compose
For IM 6
Code: Select all
convert background image overlayimage -gravity center -compose over -composite resultimage
For IM 7
Code: Select all
magick background image overlayimage -gravity center -compose over -composite resultimage
Re: Command for merging 2 image files
Oh, sorry
⟫ apt-cache policy imagemagick
Code: Select all
imagemagick:
Installed: 8:6.8.9.9-7ubuntu5.3
Candidate: 8:6.8.9.9-7ubuntu5.3
Version table:
*** 8:6.8.9.9-7ubuntu5.3 100
100 /var/lib/dpkg/status
8:6.8.9.9-7 500
500 http://ubuntu.01link.hk xenial/main amd64 Packages
⟫ convert -version
Code: Select all
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-29 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
Thanks for your advice. Following command works for me;The basic concept is -compose over -composite. See http://www.imagemagick.org/Usage/compose/#compose
For IM 6
For IM 7Code: Select all
convert background image overlayimage -gravity center -compose over -composite resultimage
If these do not work, please post your images to some free hosting service such as dropbox.com and put the URLs here.Code: Select all
magick background image overlayimage -gravity center -compose over -composite resultimage
Code: Select all
⟫ composite -blend 80 -gravity center chinese_08_transp.png scenery-008.jpg output_file.png
If I expect the Text to be at center bottom what flag shall I use? Thanks
Regards
satimis
- 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
You can post your images to some free hosting service such as dropbox.com and put the URL here.
You would be better off using convert .... -composite, rather than composite. The former is more flexible.
Depending upon how big your text image is relative to your background, use -gravity south -geometry +X+Y.
Once I see your images, I can give you a better command.
You would be better off using convert .... -composite, rather than composite. The former is more flexible.
Depending upon how big your text image is relative to your background, use -gravity south -geometry +X+Y.
Once I see your images, I can give you a better command.
Re: Command for merging 2 image files
Your advice noted. Thanksfmw42 wrote: ↑2017-04-14T09:06:52-07:00 You can post your images to some free hosting service such as dropbox.com and put the URL here.
You would be better off using convert .... -composite, rather than composite. The former is more flexible.
Depending upon how big your text image is relative to your background, use -gravity south -geometry +X+Y.
Once I see your images, I can give you a better command.
Photo on Dropbox
https://www.dropbox.com/s/u5agltgofyd5s ... e.png?dl=0
Regards
satimis
- 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
I was also asking for your input images and/or definition of text.
- 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
I only see your output file at the link above. Please post the URLs to the other files.
Re: Command for merging 2 image files
Oh sorry. Tried again
Input file - Text
https://www.dropbox.com/s/h7475qdtjqipw ... p.png?dl=0
Input file - background
https://www.dropbox.com/s/kyqqa4mcmg3pn ... 8.jpg?dl=0
Output file
https://www.dropbox.com/s/u5agltgofyd5s ... e.png?dl=0
- 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
This is the more current command for IM 6. If IM 7 change "convert" to "magick"
If you want the text offset from the center, then add -geometry +X+Y right after -gravity center, where X is the horizontal shift and Y is the vertical shift.
see
http://www.imagemagick.org/script/compose.php
http://www.imagemagick.org/Usage/layers/#convert
If you want to resize the text image, then use parenthesis processing such as
Unix syntax:
Windows syntax:
where X here is the resize percent. See http://www.imagemagick.org/script/comma ... php#resize and http://www.imagemagick.org/script/comma ... p#geometry
Code: Select all
convert scenery-008.jpg chinese_08_transp.png -gravity center -define compose:args=80 -compose blend -composite result.png
see
http://www.imagemagick.org/script/compose.php
http://www.imagemagick.org/Usage/layers/#convert
If you want to resize the text image, then use parenthesis processing such as
Unix syntax:
Code: Select all
convert scenery-008.jpg \( chinese_08_transp.png -resize X% \) -gravity center -define compose:args=80 -compose blend -composite result.png
Windows syntax:
Code: Select all
convert scenery-008.jpg ( chinese_08_transp.png -resize X% ) -gravity center -define compose:args=80 -compose blend -composite result.png
Re: Command for merging 2 image files
Hi,fmw42 wrote: ↑2017-04-14T20:00:46-07:00 This is the more current command for IM 6. If IM 7 change "convert" to "magick"
If you want the text offset from the center, then add -geometry +X+Y right after -gravity center, where X is the horizontal shift and Y is the vertical shift.Code: Select all
convert scenery-008.jpg chinese_08_transp.png -gravity center -define compose:args=80 -compose blend -composite result.png
see
http://www.imagemagick.org/script/compose.php
http://www.imagemagick.org/Usage/layers/#convert
If you want to resize the text image, then use parenthesis processing such as
Unix syntax:
Code: Select all
convert scenery-008.jpg \( chinese_08_transp.png -resize X% \) -gravity center -define compose:args=80 -compose blend -composite result.png
Windows syntax:
where X here is the resize percent. See http://www.imagemagick.org/script/comma ... php#resize and http://www.imagemagick.org/script/comma ... p#geometryCode: Select all
convert scenery-008.jpg ( chinese_08_transp.png -resize X% ) -gravity center -define compose:args=80 -compose blend -composite result.png
Performed following tests;
1)
Code: Select all
⟫ convert scenery-008.jpg chinese_08_transp.png -gravity center -define compose:args=80 -compose blend -composite result_01.png
https://www.dropbox.com/pri/get/result_ ... A20mp6S1zg
2)
Code: Select all
⟫ convert scenery-008.jpg \( chinese_08_transp.png -resize 150% \) -gravity center -define compose:args=80 -compose blend -composite result_02.png
https://www.dropbox.com/pri/get/result_ ... CgSJwvsutA
3)
Code: Select all
⟫ convert scenery-008.jpg chinese_08_transp.png -gravity center -geometry +0+400 -define compose:args=80 -compose blend -composite result_05.png
https://www.dropbox.com/pri/get/result_ ... lF8ET5s9DQ
4)
Code: Select all
⟫ convert scenery-008.jpg chinese_08_transp.png -gravity center -geometry +0-400 -define compose:args=80 -compose blend -composite result_06.png
https://www.dropbox.com/pri/get/result_ ... GP_B83WDOg
Referring to 3) and 4)
Why +0+400 (y=+400) moving the Text to bottom not to top?
Why +0-400 (y=-400) moving the Text to top not to bottom?
If I need ;
1) adding another image_02.jpg to the top right sector of the background.
2) the Text images is still in the center retaining its original size
3) image_02.jpg to be in a circle trimmed, size any such for testing
image_02.jpg
https://www.dropbox.com/pri/get/image_0 ... DOcU27Gfbg
What will be the command?
Or I need to do it with 2 commands (2 steps)?
Thanks
Regards
satimis
- 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
Sorry it appears that you have used a private directory at dropbox and I would need login/password access. But, you can make the links to these files shareable. Dropbox recently changed their public folder so that it is not shareable as I recall. So read the instructions for making a link shareable to a file.
Re: Command for merging 2 image files
Oh, sorry,fmw42 wrote: ↑2017-04-16T10:54:09-07:00 Sorry it appears that you have used a private directory at dropbox and I would need login/password access. But, you can make the links to these files shareable. Dropbox recently changed their public folder so that it is not shareable as I recall. So read the instructions for making a link shareable to a file.
Just recreated the links making them shareable.
result_01.png
https://www.dropbox.com/s/63pkyroqtwo9n ... 1.png?dl=0
result_02.png
https://www.dropbox.com/s/93fdjhtfshjvi ... 2.png?dl=0
result_05.png
https://www.dropbox.com/s/zi6s2fezdufdh ... 5.png?dl=0
result_06.png
https://www.dropbox.com/s/3p0sw9oiw9er5 ... 6.png?dl=0
image_02.jpg
https://www.dropbox.com/s/99q6efhcywznf ... 2.jpg?dl=0
Regards
satimis
- 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
In Imagemagick, rows increase downward (as positive). The 0,0 pixel is at the top left.Referring to 3) and 4)
Why +0+400 (y=+400) moving the Text to bottom not to top?
Why +0-400 (y=-400) moving the Text to top not to bottom?
You can change the gravity setting to north if you want the text aligned at the top or northwest if you want the text aligned top left.
- 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
Try this:If I need ;
1) adding another image_02.jpg to the top right sector of the background.
2) the Text images is still in the center retaining its original size
3) image_02.jpg to be in a circle trimmed, size any such for testing
Code: Select all
dim=`convert image_02.jpg -format "%[fx:min(w,h)]\n" info:`
dim2=`convert xc: -format "%[fx:$dim/2]" info:`
convert scenery-008.jpg chinese_08_transp.png \
-gravity center -define compose:args=80 -compose blend -composite \
\( image_02.jpg -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 northeast -compose over -composite \
result.png