0

How can I create an Image using Imagemagick in which I stick for example 6 images next to each other, thus the background shall be transparent(.png file).

It shall look something like this: ( The black rectangles shall represent images )

enter image description here

How do I achieve this ?

Edit (Update)

So far I have done this image:

enter image description here

using this command:

montage img1.jpg img2.jpg img3.jpg img4.jpg img5.jpg img6.jpg -geometry +10+10 -resize 720x480 output.jpg

but I am not sure how to proceed further.

utdev
  • 3,942
  • 8
  • 40
  • 70

2 Answers2

2

You are almost there! Take your montage command and output the resulting 3x2 montage to stdout as a PNG into a new convert which appends it below your top.jpg image:

montage im*jpg -geometry +10+10 png:- | convert -gravity north top.jpg png:- -append result.png

enter image description here

If you are on Windows, you probably need:

montage *.jpg ...

or you can type it out in full:

montage img1.jpg img2.jpg img3.jpg img4.jpg img5.jpg img6.jpg -geometry +10+10 png:- | convert -gravity north top.jpg png:- -append result.png
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • It means all files starting with `im` and ending in `jpg`. It's just shorter to type. – Mark Setchell Sep 22 '16 at 09:24
  • ah ok I see, what would it look like in the longer version? – utdev Sep 22 '16 at 09:26
  • if I run your code / command (short version) I get following message in my console convert.exe: improper image header `-' @ error/png.c/ReadPNGImage/3986 – utdev Sep 22 '16 at 09:33
  • Thank you, I tried your updated code but I still get the same message – utdev Sep 22 '16 at 09:48
  • Did you use copy and paste, or type it? What OS do you use? Do you have an image named `top.jpg` to use as the top image? – Mark Setchell Sep 22 '16 at 10:13
  • I copy pasted, I am working on Windows 10, I do have an image named top.jpg, thus my imagemagick version is 7.0.2-0 Q16 x64. Btw does the command work on your machine? – utdev Sep 22 '16 at 10:17
  • another question what does `png:-` do? – utdev Sep 22 '16 at 11:10
  • Of course it works on my machine! ;-) The first `png:-` means that `montage` should write its resulting image as a `PNG` image onto its standard output, and the second one means that `convert` should expect to read a `PNG` image from its standard input and, as I joined the standard output of `montage` to the standard input of `convert` using the pipe (`|`), the image should pass from one program to the next. – Mark Setchell Sep 22 '16 at 14:22
  • Try replacing both `png:-` with `miff:-` – Mark Setchell Sep 22 '16 at 16:59
  • replacing both png:- to miff:- did not change anything, the command line does not give me any feedback – utdev Sep 27 '16 at 13:36
  • And if you type `convert /?` – Mark Setchell Sep 27 '16 at 13:53
0

This is just another way of doing this. I think it may be a little simpler than Mark's solution. Note the parentheses that groups commands into single image ouput. Also remember that IM requires space before and after the openining brackets.

magick -gravity center -background none -bordercolor none ( f1.jpg -border 10 ) ( f2.jpg f3.jpg f4.jpg -border 10 +append ) ( f5.jpg f6.jpg f7.jpg -border 10 +append ) -append output.png

More on appending is here however in most cases I prefer montage command.

rostok
  • 2,057
  • 2
  • 18
  • 20