How do I 'tile' an image like this?

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
michrome
Posts: 4
Joined: 2011-07-27T02:49:43-07:00
Authentication code: 8675308

How do I 'tile' an image like this?

Post by michrome »

Hi all. I'm new to using ImageMagick, looking for some syntax advice.

I have an image that I'd like to tile into a larger image but I'd also like the columns to be shifted 50% of the image height. It's probably easier to show an example of what I'm trying to do:

Start with this:
Image

Finish with this:
Image


Please could someone tell me the ImageMagick command I should be using to do this?

Many thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How do I 'tile' an image like this?

Post by fmw42 »

You need to roll the image by half and append it to the original, then tile it out. The following works, but there may be a more efficient way -- see http://www.imagemagick.org/Usage/canvas/#tile

The following method uses in-memory image (mpr:) to store the results of the append so that a separate image does not have to be saved.

infile="22e4gx.png"
h2=`convert $infile -format "%[fx:round(h/2)]" info:`
convert $infile \( -clone 0 -roll +0+$h2 \) +append \
-write mpr:sometile +delete -size 1000x500 tile:mpr:sometile \
22e4gx_tiled.png


The above use of variables in unix. If you are on Windows, see http://www.imagemagick.org/Usage/windows/
michrome
Posts: 4
Joined: 2011-07-27T02:49:43-07:00
Authentication code: 8675308

Re: How do I 'tile' an image like this?

Post by michrome »

Fred

That's brilliant, thanks so much! Love your web site too: there's some really useful examples on there.

Thanks again!

Mike
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How do I 'tile' an image like this?

Post by anthony »

This is also known as 'hex tiling' which is discussed in IM examples
http://www.imagemagick.org/Usage/canvas/#tile_hex

It shows how you can layer the images together. You can ignore the issues of size, and the later effects.

Another user of ImageMagick also looked at cutting out actual Hexagons, and Triangles, and then piecing them together again. The major problem he had however involved generating a good mask (with angled joins) that would then fit together properly. Mask creation in that case can become very tricky when you want to don't want to generate overlaps, or gaps, though some 'cheats' can make this easier.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply