Stick images next to each other

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
utbl
Posts: 18
Joined: 2016-09-22T01:53:33-07:00
Authentication code: 1151

Stick images next to each other

Post by utbl »

How can I create an Image in which I stick for example 6 images next to each other.
The background shall be transparent aswell(.png file).

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

http://postimg.org/image/fmfl5d6tf

So far I have done this

http://postimg.org/image/t2u5z1ocx

using this code:

Code: Select all

montage image1.jpg image2.jpg image3.jpg image4.jpg image5.jpg image6.jpg -geometry +10+10 -resize 720x480 output.png
but I am not sure how to proceed further.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Stick images next to each other

Post by GeeMack »

utbl wrote:

Code: Select all

montage image1.jpg image2.jpg image3.jpg image4.jpg image5.jpg image6.jpg -geometry +10+10 -resize 720x480 output.png
but I am not sure how to proceed further.
There are several ways to approach this sort of project. Often the best way depends on the version of ImageMagick you're using. Sometimes the OS you're working on makes a difference, too. To make an arrangement like your example I'd probably use "convert" instead of "montage". A simple command on a Windows command line with a recent version 6 of IM and might look like this...

Code: Select all

convert -bordercolor none -background none -gravity center ^
   img1.jpg -border 5x5 ^
   ( img2.jpg img3.jpg img4.jpg -border 5x5 +append ) ^
   ( img5.jpg img6.jpg img7.jpg -border 5x5 +append ) ^
   -append -border 5x5 -resize 720x480 output.png
That makes three rows starting with the first image as the top row, then the next three, then the last three, then it appends those three rows into a column. Everything is spaced apart by 5 pixel transparent borders and placed on a transparent background, and the final output is surrounded by another 5 pixel border then sized to 720x480.

If this needs to be done for a whole directory of images, or automated, or take into account odd sizes or different arrangements every time, other methods might turn out to be a better approach. Give us a few more details, and let us know which version of IM you're using and what platform your working on.
utbl
Posts: 18
Joined: 2016-09-22T01:53:33-07:00
Authentication code: 1151

Re: Stick images next to each other

Post by utbl »

Thank you I will try this out I got a little question what means ^ in the command that confused me a bit
utbl
Posts: 18
Joined: 2016-09-22T01:53:33-07:00
Authentication code: 1151

Re: Stick images next to each other

Post by utbl »

Thank you I will try this out and reply you later, I got one question left what the sign ^ mean in your command?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Stick images next to each other

Post by GeeMack »

utbl wrote:Thank you I will try this out and reply you later, I got one question left what the sign ^ mean in your command?
When running a command at a Windows command prompt, the caret "^" indicates there are more lines to the command. You could make a command like that as one long line without those line breaks, but sometimes that makes it harder to see what's actually going on. Things like that work differently on a Linux type system. The commands are almost the same, but you have to change certain tiny details to make them work. That's why we can't give you any specific help if we don't know what operating system you're using or what version of ImageMagick you're using.
utbl
Posts: 18
Joined: 2016-09-22T01:53:33-07:00
Authentication code: 1151

Re: Stick images next to each other

Post by utbl »

I am working on a windows machine (windows 10) with ImageMagick 7.0.2-0 Q16 x64
utbl
Posts: 18
Joined: 2016-09-22T01:53:33-07:00
Authentication code: 1151

Re: Stick images next to each other

Post by utbl »

Great thank you, your command works if I write in down in the command line. The problem is that I need to do this in the windows powershell, if I write it down in my powershell it gives me an error which tells me that img2.jpg could not be found as a name of the cmdlet, a function or scriptfile ...
Do you know how I have to change the command to let it work on the powershell?
Post Reply