Tiler是一款马赛克镶嵌画制作工具

基于Python 开发, 遵守MIT开源协议。Tiler 制作的镶嵌画可以适应不同形状和大小的图块(不限于方块)。

使用方法:

图片放到images 目录下。

之后,选择需要镶嵌的图块。Tiler 自带多种图块,例如选择 圆点作为镶嵌图块,例如图块 tiles/dot 目录:
dot
├── dot.png
└── gen_at

说明:
    dot.png 是图块的原始图片。
    gen_at 为图块目录,其中包含各种颜色的圆点。

在 tiler 目录中执行以下命令:
python tiler.py ./images/目标图片.png ./tiles/dot/gen_at/ 

完成后,tiler 目录中会生成 out.png

配置参数
可使用默认配置如果需要可调整,可调大配置文件 tiler/conf.py 中 DEPTH 和 COLOR_DEPTH 的值。

    DEPTH :每种颜色的分区数,默认值 4。
    COLOR_DEPTH :图片包含颜色的数量,默认值 32。

源码:https://github.com/nuno-faria/tiler

-----------------------------------------------------

About

Tiler is a tool to create an image using all kinds of other smaller images (tiles). It is different from other mosaic tools since it can adapt to tiles with multiple shapes and sizes (i.e. not limited to squares).

An image can be built out of circles, lines, waves, cross stitches, legos, minecraft blocks, paper clips, letters, ... The possibilities are endless!

Installation

  • Clone the repo: git clone https://github.com/nuno-faria/tiler.git;
  • Install Python 3;
  • Install pip (optional, to install the dependencies);
  • Install dependencies: pip install -r requirements.txt

Usage

  • Make a folder with the tiles (and only the tiles) to build the image;
    • The script gen_tiles.py can help in this task; it builds tiles with multiple colors based on the source tile (note: its recommended for the source file to have an RGB color of (240,240,240)). It is used as python gen_tiles.py path/to/image and creates a folder with a 'gen_' prefix in the same path as the base image.
  • Run python tiler.py path/to/image path/to/tiles_folder/.

Configuration

All configurations can be changed in the conf.py file.

gen_tiles.py

  • DEPTH - number of divisions in each color channel (ex: DEPTH = 4 -> 4 * 4 * 4 = 64 colors);
  • ROTATIONS - list of rotations, in degrees, to apply over the original image (ex: [0, 90]).

tiler.py

  • COLOR_DEPTH - number of divisions in each color channel (ex: COLOR_DEPTH = 4 -> 4 * 4 * 4 = 64 colors);
  • RESIZING_SCALES - scale to apply to each tile (ex: [1, 0.75, 0.5, 0.25]);
  • PIXEL_SHIFT - number of pixels shifted to create each box (ex: (5,5)); if None, shift will be the same as the tile dimension);
  • OVERLAP_TILES - if tiles can overlap;
  • RENDER - render image as its being built;
  • POOL_SIZE - multiprocessing pool size;
  • IMAGE_TO_TILE - image to tile (ignored if passed as the 1st arg);
  • TILES_FOLDER - folder with tiles (ignored if passed as the 2nd arg);
  • OUT - result image filename.

Examples

Circles

Various sizes

Original cake image by pongsakornred from FLATICON.

Fixed

  • 10x10

- 25x25

- 50x50

 

Paper clips

Cross stitch (times)

 

Hearts

Legos

Minecraft blocks

from 

https://github.com/nuno-faria/tiler