Adjust identicons to match ivatar (10x10, padding, colors, retro = identicon).
the build was successful Details

This commit is contained in:
tastytea 2019-02-20 22:40:29 +01:00
parent abe643bb6c
commit fba5c64486
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 26 additions and 21 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
project(libravatarserv
VERSION 0.7.1
VERSION 0.7.2
LANGUAGES CXX
)

View File

@ -21,7 +21,7 @@ The API is explained in greater detail at the
* OpenID
* Because it isn't possible to store filenames with '/' in it on most filesystems.
* The default fallbacks monsterid, wavatar, retro and robohash
* The default fallbacks monsterid, wavatar and robohash
* Patches welcome
## Usage

View File

@ -101,28 +101,33 @@ int main()
goto not_implemented;
}
}
else if (avatar.fallback.substr(0, 9) == "identicon")
else if (avatar.fallback.substr(0, 9) == "identicon" ||
avatar.fallback.substr(0, 5) == "retro")
{
try
{
Identiconpp identicon(4, 4, Identiconpp::algorithm::sigil,
"ffffffff",
{ // The 16 named colors specified in HTML 4.01
// minus white, silver and gray.
"000000ff", // Black
"ff0000ff", // Red
"800000ff", // Maroon
"ffff00ff", // Yellow
"808000ff", // Olive
"00ff00ff", // lime
"008000ff", // Green
"00ffffff", // Aqua
"008080ff", // Teal
"0000ffff", // Blue
"000080ff", // Navy
"ff00ffff", // Fuchsia
"800080ff", // Purple
});
uint8_t padwidth = avatar.size / 10;
if (avatar.size < 60)
{
padwidth = 0;
}
else if (padwidth < 10)
{
padwidth = 10;
}
Identiconpp identicon(10, 10, Identiconpp::algorithm::sigil,
"#fefefe",
{ // The same colors ivatar uses.
"2d4fffff", // Blue
"feb42cff", // Yellow
"e279eaff", // Bright pink
"1eb3fdff", // Cyan
"E84D41ff", // Red
"31CB73ff", // Green
"8D45AAff" // Dark pink
},
{ padwidth, padwidth });
image.image = identicon.generate(avatar.digest, avatar.size);
image.image.magick("PNG");
image::write(image);