DEV Community

Cover image for Redraw a masterpiece with mosaic pictures
Pierre Grimaud
Pierre Grimaud

Posted on

Redraw a masterpiece with mosaic pictures

Today, my brilliant intern @nispeon finished a small project I imagined last year: redraw a masterpiece with mosaic pictures.

Explanation of the project

I created an exercice for him, to work with python, GitHub API and GitHub Actions.

Main goal: redraw a masterpiece with mosaic pictures.

We would have been able to use a random sample of pictures to do this exercice, but we thought it could be funny for visitors to check where's their avatar on the generated picture.

We found a nice project Photomosaic generator by Viet Nguyen to generate mosaic with pictures.

So we decided to re-use his code base which works perfectly.

How is generated the picture?

Each day, the script will :

  • Fetch all stargazers of the repository using GitHub API
  • Download avatar picture of all users
  • Extract main color of each avatar picture
  • Split origin picture into small parts of 30px
  • Extract main color of each part of the origin picture
  • Match color of each part with the color of an avatar and replace it on the origin picture
  • Write the new picture on a folder
  • Commit the picture generated using GitHub Actions

How you can help

We will not add random people without permission, so if you would like to participate: you just have to star this repository.

Why do you need to star to participate? Because it will be very easy to retrieve all avatars with GitHub API and automatically update the image every day.

The more stargazers we will get, more qualitative will be the output. We could also reduce the size of the avatars to get best definition.

First result

Original picture :

original picture

Output picture :

output picture

Take a look at the HD generated picture and the repository 👀

What do you think about it?

 
Pierre 🤖
 

__
Connect with me on GitHub
Connect with me on Twitter

Top comments (1)

Collapse
 
iceorfiresite profile image
Ice or Fire

Pretty cool!