Skip to content
This repository was archived by the owner on Sep 9, 2021. It is now read-only.

jimmyprior/brickify-old

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THIS IS AN OLD VERSION. SEE VERSION 2 FOR A BIG UPDATE.

Brickify

Turn images into lego mosaics.

Example

Code Sample

from PIL import Image
from brickify import EditedImage, PieceList, RenderedImage
from defaults.palettes import all   #use the default lego color palette 
from defaults.pieces import medium #use medium piece sizes 


IMAGE = 'barack.jpg'
INPUT_PATH = 'input/'
OUTPUT_PATH = 'output/'

SIZE = (96, 96)   # each pixel will be treated as a (1x1) lego brick

im = Image.open(INPUT_PATH + IMAGE)   # open the image

edited = EditedImage(image = im).edit_image(size = SIZE, palette = all) #resize the image and recolor it to the lego colors
pieces = PieceList(image = edited).generate_medium(pieces = medium)  #use medium sized pieces and generate with medium speed. 
#Medium speed is not optimized to fit the biggest piece when possible. 
#use the generate_slow method if you're looking for optimization.
#use the generate_fast method if you're looking for speed.  

render = RenderedImage(piece_list = pieces, size = SIZE).render_image() #render the piecelist into a visual form. 

render.save(OUTPUT_PATH + IMAGE) #save the render you created. 

Image Output

Image

Other Examples

Image Image

Image Image

Image Image

About

Convert images into lego mosaics

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages