Using ImageMagick to repeat or "tile" an image
Asked Answered
D

4

23

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!

Dunaway answered 18/11, 2011 at 12:58 Comment(0)
D
14

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.

Dunaway answered 20/11, 2011 at 14:33 Comment(0)
W
33

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.

Warbler answered 3/8, 2017 at 16:59 Comment(4)
same usage on linux: convert -size 800x600 tile:Ball.jpg Tiles.jpgSandbox
@MarinosAn funny that tile: cannot come before -size ?Wendt
@Wendt I guess it's because the tile pseudo-image format is specified as prefix in the filename. And according to convert manpage, input filename should be placed before input options: convert [input-option] input-file [output-option] output-fileSandbox
Can you add a border around the tiles ? Like montage's -geometry optionFunk
D
14

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.

Dunaway answered 20/11, 2011 at 14:33 Comment(0)
W
9

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

Wrasse answered 22/4, 2016 at 21:29 Comment(0)
C
2

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

Coexist answered 3/8, 2017 at 18:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.