The example images above are generated using example.cpp.
|
4 months ago | |
---|---|---|
cmake | 1 year ago | |
examples | 1 year ago | |
include | 1 year ago | |
pkg-config | 1 year ago | |
src | 1 year ago | |
tests | 1 year ago | |
.drone.yml | 4 months ago | |
.editorconfig | 4 months ago | |
.gitignore | 2 years ago | |
CMakeLists.txt | 4 months ago | |
CODE_OF_CONDUCT.adoc | 1 year ago | |
CONTRIBUTING.adoc | 1 year ago | |
Doxyfile | 1 year ago | |
LICENSE | 2 years ago | |
README.adoc | 4 months ago | |
build_doc.sh | 1 year ago | |
packages.CMakeLists.txt | 4 months ago |
identiconpp is a library to generate identicons for C++.
You get the images as Magick::Image
. This allows you to make all kinds of
modifications.
The example images above are generated using example.cpp.
✓ Symmetric identicons
✓ sigil identicons
✓ Asymmetric identicons
✓ Padding
The HTML reference can be generated with build_doc.sh
, if doxygen is
installed. It is also available at
doc.schlomp.space/identiconpp/.
You need to generate hashes yourself, any hexadecimal string will do. Make sure to use a safe hashing algorithm for sensitive data (not MD5). You can select as many columns and rows as you like, but make sure you have enough entropy. If something seems to be wrong, exceptions will be thrown.
The "sigil" algorithm generates the same results as sigil and pydenticon.
// Compile with g++ $(pkg-config --libs --cflags identiconpp)
#include <iostream>
#include <identiconpp.hpp>
#include <Magick++/Image.h>
int main()
{
Identiconpp identicon(5, 5, Identiconpp::algorithm::ltr_symmetric,
"ffffff80", { "800000ff" }, { 10, 10 });
Magick::Image img;
img = identicon.generate("55502f40dc8b7c769880b10874abc9d0", 200);
img.write("identicon.png");
std::cout << identicon.generate_base64("png", "5550", 200) << std::endl;
}
Gentoo ebuilds are available via my repository.
Binary packages are generated automatically for each release. They are signed with my automatic signing key.
cmake (at least 3.6)
imagemagick (tested: 7.0 / 6.7)
Optional:
On a Debian system, install the packages:
build-essential cmake libmagick++-dev
.
mkdir build
cd build
cmake ..
cmake --build .
make install
-DCMAKE_BUILD_TYPE=Debug
for a debug build
-DWITH_TESTS=YES
to build tests
One of:
-DWITH_DEB=YES
to generate a deb-package
-DWITH_RPM=YES
to generate an rpm-package
To generate a binary package, run make package
.
Read the Code of Conduct.
Before reporting a bug, please perform a search to see if the problem has already been reported. If it has, add a comment to the existing issue instead of opening a new one. Same for enhancements.
Please use similar coding conventions as the rest of the project. The basic rule to remember is to write code in the same style as the existing/surrounding code.
You can also send me your patches via E-Mail, ideally
using git format-patch
or git send-email
.
Create image with width=columns, height=rows.
Set background color.
Select half of the columns, or half of the columns + 1 if uneven.
columns / 2 + columns % 2
Pixels are drawn from left to right, top to bottom.
Use bits from digest to determine if a pixel is painted(1) or not(0).
Mirror the pixels vertically.
Use the following bits to pick the foreground color.
You need floor(log2(n_colors)) + 1
bits.
Scale image proportionally to requested width.
0111 0011 1101 1100 […] 1111 0111 0101 0111 ^ ^ +----------------------------+--------------> | | pixel matrix foreground color
Implemented in ltr_symmetric.cpp.
Create image with width=columns, height=rows.
Set background color.
Pixels are drawn from left to right, top to bottom.
Use bits from digest to determine if a pixel is painted(1) or not(0).
Use the following bits to pick the foreground color.
You need floor(log2(n_colors)) + 1
bits.
Scale image proportionally to requested width.
0111 0011 1101 1100 […] 1111 0111 0101 0111 ^ ^ +----------------------------+--------------> | | pixel matrix foreground color
Implemented in ltr_asymmetric.cpp.
Create image with width=columns, height=rows.
Set background color.
Select half of the columns, or half of the columns + 1 if uneven.
columns / 2 + columns % 2
Pixels are drawn from top to bottom, left to right.
Use the first 8 bits to pick the foreground color.
Use the following bits to determine if a pixel is painted(1) or not(0).
Mirror the pixels vertically.
Scale image proportionally to requested width.
0111 0011 1101 1100 ^ ^ +---------+---------> | | foreground color | pixel matrix
Implemented in sigil.cpp.