Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.3 KB

README.md

File metadata and controls

37 lines (27 loc) · 1.3 KB

What is png-mean-color?

This is an utility to calculate the mean color of a png file and print the resulting color in HEX format, suitable for use on CSS and HTML.

Why?

I really liked the way Chrome picks the color used around thumbnails of websites on their "Most Visited" page and wanted to do that on a program I was developing so I found this thread on Quora explaining the algorithm and pointing to the code location on Chromium repository.

The original code needed Skia to work and had a bunch of dependencies. I removed all dependencies except libpng and maintained the BSD-style license of the original code.

How?

You can build it using cmake:

$ git clone https://github.com/edufelipe/png-mean-color.git
$ mkdir build && cd build
$ cmake ../ && make
$ cp png-mean-color /usr/local/bin

Then all you have to do is pass in a PNG file:

$ png-mean-color some_file.png
#fe6f04