Question

How do I tile an image using ImageMagick? I don't think I can use montage because I want the columns displaced by 50% of the original image height.

It's probably easier to show an example of what I'm trying to do:

Start with:

enter image description here

End with:

enter image description here

Thanks!

Was it helpful?

Solution 2

Thanks to Fred at Fred's ImageMagick Scripts, here's the solution:

infile="tile.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 output.png

This is exactly what I was looking for.

OTHER TIPS

In case you want plain tiles, without shifting down the second column and the rest of the even columns, you can use this script:

convert -size 800x600 tile:Ball.jpg Tiles.jpg

(probably the majority of people landing on this question want such plain tiles, like I did)

My "Ball.jpg" is 200 x 200 pixels, so this script creates a 4x3 tile image.

For ImageMagick 7 users, replace convert with magick.

Even though you did not mention anything about context of usage, I will put it here so more people are aware. Fred's scripts are for non-commercial use. I ended with an alternative solution, however, principle is the same:

  1. Creating shifted tile by:

    convert _orange_270.jpg -roll +0+135 _orange_270_r.jpg

  2. Create a column of regular tiles:

    montage _orange_270.jpg +clone +clone +clone -tile x4 -geometry +0+0 _1col.jpg

  3. Create a column of shifted tiles:

    montage _orange_270_r.jpg +clone +clone +clone -tile x4 -geometry +0+0 _2col.jpg

  4. Combined regular and shifted columns:

    montage -geometry +0+0 _1col.jpg _2col.jpg _2cols.jpg

  5. Created full tiled image using last output from point 4:

    convert _2cols.jpg -write mpr:tile +delete -size 1920x1080 tile:mpr:tile _wallpap.jpg

Result:

enter image description here

If on a unix-like system with ImageMagick, you could just use my script, tileimage at http://www.fmwconcepts.com/imagemagick/tileimage/index.php.

It provides numerous variations on the flipping, rotation and offsets.

If non-commercial use, then it is free, If commercial use, then contact me for a license.

Information about tiling in ImageMagick can found at http://www.imagemagick.org/Usage/canvas/#tile

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top