diff --git a/CMakeLists.txt b/CMakeLists.txt index 59c29d7..42ab06a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(libravatarserv - VERSION 0.7.1 + VERSION 0.7.2 LANGUAGES CXX ) diff --git a/README.md b/README.md index 3106169..9cf5da6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/libravatarserv.cpp b/src/libravatarserv.cpp index 09014f9..2faf2ae 100644 --- a/src/libravatarserv.cpp +++ b/src/libravatarserv.cpp @@ -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);