how do i create a "border" of made of images?

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
joshuascottpaul
Posts: 1
Joined: 2012-09-14T08:58:54-07:00
Authentication code: 67789

how do i create a "border" of made of images?

Post by joshuascottpaul »

how do i create a "border" of made of images?

imagine i have 8 images (3x3) images or 12 (4x4)
i like to create a square "border" with those images - leaving the center empty

i can imagine doing it using the montage command in two steps

step 1 creating 3 rows (or columns) - inserting the null: where appropriate
step 2 combining the 3 rows into a single image to form a square

is there a single step way to do this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how do i create a "border" of made of images?

Post by fmw42 »

I would think you could use montage with all 8 images and a null: between image 4 and 5, but I have not tested that. Just set the -background to none or transparent. See http://www.imagemagick.org/Usage/montage/#settings

You can do it with convert using successive pairs of -compose -composite commands and each -gravity except the center for the 3x3 case to insert the image in a transparent background image large enough for all 9 spaces. The 4x4 would require -geometry also. Or you could use -flatten on all of them in one command, but you need to specify the -page coordinates.

see

http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/layers/#flatten
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: how do i create a "border" of made of images?

Post by anthony »

I would probably create two tiled images from the original See Tiling with an Image already In Memory , one for inside, one for outside, then use -gravity center -compose DstOut -composite to remove the center from the larger. that would be simplest...

But here is a append solution...

use -duplicate to create an image for the top and bottom border images. create a clone of the original make transparent and use it with the original to create a middle row. duplicate the middle row then the first top row, and append all together.

Hmmm a 7x5 border of rose images...

Code: Select all

convert rose: -alpha set \
            \( +clone -duplicate 6 +append \) \
            \( -clone 0 -channel A -negate +channel -duplicate 4 \
               -clone 0 -clone 0 +insert +append \) \
           -delete 0 -duplicate 2 -duplicate 1,0 \
            -append    rose_border.png
First parenthesis creates the top border (6 = length -1)
second parenthesis, one middle row (4 = length -3)
then delete original image, duplicate middle row (2 = height -3)
duplicate top row as bottom row, and append vertically.

There are other solutions too.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply