Tiling the plane with a single small image (montage)

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
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Tiling the plane with a single small image (montage)

Post by dargaud »

Hello all,
I'm trying to do something simple: tile a large area with a small image.
The following command works for putting together 128x128 tiny 2x2 images in a 256x256 square:

Code: Select all

NB=128; time montage -tile $NBx$NB $( for (( c=1; c<=$((NB*NB)); c++)) ; do echo "Tiny.png" ; done ) -geometry 2x2+0+0 Tiling.png
But it already takes 20 seconds, and raising it to 256 takes a whooping 7 minutes ! Since I want to go higher than that, it's not a good solution.
Anybody can suggest a faster alternative ?
Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Tiling the plane with a single small image (montage)

Post by snibgo »

Your method is ingenious, but involves reading the same image file 16384 times. It's hard to think of a slower method.

A faster method:

Code: Select all

convert -size 2x2 gradient:red-blue r.png

convert -size 256x256 tile:r.png rt.png
EDIT: I should point out that "-size 256x256" is the number of pixels in the final image, not the number of repetitions. Using "-size 25600x25600" takes 20 seconds.
snibgo's IM pages: im.snibgo.com
dargaud
Posts: 31
Joined: 2006-08-06T01:58:58-07:00

Re: Tiling the plane with a single small image (montage)

Post by dargaud »

THanks. I'd indeed searched for the word 'tile' in the documentation and found "-tile", but not "tile:"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Tiling the plane with a single small image (montage)

Post by fmw42 »

see this and the subsequent sections for all the tiling methods. http://www.imagemagick.org/Usage/canvas/#tile
Post Reply