Page 1 of 1

Border Pattern

Posted: 2013-03-25T08:37:22-07:00
by dognose
I'm trying to paste an image a number of times around the image.
like so:
Image

I don't want to composite the image 20 times and calculate each position of each overlay

Is there a simpler way to draw a repeating pattern?

Re: Border Pattern

Posted: 2013-03-25T08:48:21-07:00
by snibgo
The obvious approach is with tiles. Create a horizontally tiled image for the top and bottom, etc. See http://www.imagemagick.org/Usage/canvas/#tile

Re: Border Pattern

Posted: 2013-03-25T09:38:19-07:00
by dognose
I guess that will work, the stacking isn't going to work right though for a clean border.
the example border is really bad Image

Re: Border Pattern

Posted: 2013-03-25T09:57:29-07:00
by fmw42
Create the overlay image by tiling to the nearest integer multiply of the tile size. Mask out the inside so that the tiles are only the at the border. Then resize it to exactly fit your image. Perhaps make your tiles to have a little space around them so that it is easy to mask the inside without cutting into the tiled border.

Re: Border Pattern

Posted: 2013-03-25T09:59:40-07:00
by snibgo
Whatever method you use, the cleanest result will be when the horizontal repetition is an exact divisor of the image width, so you don't get a broken element. Likewise vertically. You might do this by padding each element. Ideally, the element has binary transparency -- either on or off. Then two elements can be placed at each corner without a problem. I would guess that partial transparency that was only for anti-aliasing would be hardly noticable when doubled-up.

If the image height or width is a prime number, there aren't any divisors, and the best placement might need SRT in a farily messy script.

EDIT: better still, as fmw says, resize the result, provided you don't mind the elements changing their aspect ratios, ie getting "squished".

Re: Border Pattern

Posted: 2013-03-25T17:03:26-07:00
by anthony
dognose wrote:I guess that will work, the stacking isn't going to work right though for a clean border.
the example border is really bad Image
This example was NOT for the border... It was for the offset of the background tiling image!

What you probably want is in Thumbnails, Framing, using edge images...
http://www.imagemagick.org/Usage/thumbnails/#frame_edge

Of course you are not wanting to add an edge, but overlay a tiled edge around the image.

Hmmm...
generate a tiled image the same size... mask it using a shaved/framed mask, then overlay on original image.
You most likely will need to know the size of the image and the tile image.

If the tile images do not tile exactly to match the destination image size, you may like to tile them to fit a image that most closly matches the distination size, then resize the overlay, after masking to fit the destination image. Note the overlay tiles be resized larger or smaller, which ever more closely matches.

Would help if we had links to original images to work with! Especially one that did not 'fit' properly.

Tiling a 'fleur' pattern may be a better final example as it also has 'corners' and different edge tiles for different edges.

I feel a new IM Example coming on, if I can get suitable 'tiles'.