The entrance to our office in Redmond in is adorned with this sculpture of our department logo, rendered in LEGO:
We had fun with LEGO bricks at work this week. APEX is our internal team name, this was fun. Oh and we're hiring for all roles in Azure! pic.twitter.com/VlNNaTexA5
— Jeff Sandquist (@jeffsand) March 30, 2017
Our team, the Cloud Developer Advocates, has a logo as well, created by the multitalented Ashley Macnamara. (The mascot's name is Bit: he's a raccoon because, like developers, he's into everything.) It would be nice to have a LEGO rendition of Bit for the wall as well, but converting an image into LEGO bricks isn't easy ... until now.
This R script by Ryan Timpe provides everything you need render an image in LEGO. It will downscale the image to a size that meets your bricks budget, convert the colors to those available as LEGO bricks, and divide the image up into LEGO-sized pieces, ready to lay out on a flat tray. The script is super easy to use: just source a file of utility functions and then:
(You can also use readJPEG to read in JPG images; I just loaded in the png package and used readPNG which works just as well.) Here's what the output looks like. (Click to see the original, for comparison.)
The script also provides a shopping list of the bricks you need by color and size: this particular project will require 1842 LEGO bricks in 19 different colors to create the 48x48 image. It will even provide a series of step-by-step instructions showing how the project will look in various stages of completion:
The R script is available on GitHub, here, and works with any recent version of R and with up-to-date tidyverse installation. (I used R 3.5.0.) You can find a complete walkthrough of using the scripts in the blog post at the link below.
Ryan Timple: How To: LEGO mosaics from photos using R & the tidyverse
HI, I have a error with my image "JPEG decompression error: Not a JPEG file: starts with 0x89 0x50" . I think that this error is about the size of my image . Is it true ?
Posted by: Alex | May 02, 2018 at 10:02
I'm guessing the error is exactly what it suggests, and your image isn't really a JPG. Sometimes you can have (say) a PNG with a ".jpg" extension. Try loading your image into an image editor and explicitly saving it as a JPEG and see if the saved file works.
Posted by: David Smith | May 02, 2018 at 10:07
You can also try read.bitmap() from the readbitmap package, which, by default, will determine the actual image type (using the image's magic numbers) regardless of the extension, and load the image (if it is JPG, PNG, BMP, or, with the development version on GitHub, TIFF).
Posted by: Derek | May 08, 2018 at 14:56