See a few more examples (here.)
How To Use
- Ruby 2.2.0 or newer
- The RMagick gem, which depends on ImageMagick. ImageMagick can be difficult to install so check the Rmagick or ImageMagick pages for instructions specific to your platform.
How to convert a gif or image
- Clone the repo, yo
cd into the directory
bundle install just in case
ruby emojisaic.rb -g [filename.gif] (for a gif)
ruby emojisaic.rb -i [filename.jpg] (for a still image)
- Marvel @ your emojisaic!
How It Works
cdinto the directory
bundle installjust in case
ruby emojisaic.rb -g [filename.gif](for a gif) or
ruby emojisaic.rb -i [filename.jpg](for a still image)
Given the image above, the program will scan it in blocks--based on the size you ultimately want the emojis to be--and find the average color for each area. Then it'll find the emoji with the closest average color and replace the area with the matching emoji:
There are options for emoji size, zoom for the completed image, random offset for each emoji's placement, and a way to prefer emojis with fewer transparent pixels.
The whole process can be pretty slow depending on the resolution you're looking for and the number of frames in your gif, so if you're doing a large GIF I'd recommend running it as a still image first, which will convert the first frame and let you see what the final output will look like.
Options, Options, Options
at least one of these are mandatory:
--gif [filename]- indicate location of the gif to convert
--image [filename]- indicate location of the still image to convert
--size [int]- height of the emoji in pixels. default is 8. smaller size = longer conversion time
--zoom [int]- multiply output file height and width by this number. default is 1. larger = longer conversion time
--offset [int]- randomly move emojis by this many pixels. default is 0. #FreeOffset
--coverage [int]- generally the emoji finder will use the emoji that is closest to the color for a given pixel area. setting this will prefer emojis with fewer transparent pixels which sometimes looks better
--quiet- silences all output and updates to the console
utilities (run these without any other options):
--tmp- deletes all temporary images in the tmp/ folder
--map- regenerate emoji color map
--help- print these options to the console
How's my driving? Tweet 1-800-@NAH_SOLO