Switched to identiconpp for identicon-generation.
This commit is contained in:
parent
519f1e8fd6
commit
1dd89882b1
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
project(libravatarserv
|
||||
VERSION 0.6.8
|
||||
VERSION 0.7.0
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
@ -42,7 +42,7 @@ file(GLOB sources src/*.cpp)
|
||||
add_executable(${CMAKE_PROJECT_NAME} "${sources}")
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
"${MAGICPP_LDFLAGS} ${LIBCRYPTOPP_LDFLAGS}"
|
||||
"${LIBXDG_BASEDIR_LDFLAGS} -lstdc++fs")
|
||||
"${LIBXDG_BASEDIR_LDFLAGS} -lstdc++fs -lidenticonpp")
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
|
@ -53,9 +53,6 @@ const string hash::sha256(const string &text)
|
||||
|
||||
bool hash::fill_table()
|
||||
{
|
||||
|
||||
|
||||
|
||||
for (const fs::path &path :
|
||||
fs::recursive_directory_iterator(settings::avatar_dir))
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <Magick++/Geometry.h>
|
||||
#include <identiconpp.hpp>
|
||||
#include "version.hpp"
|
||||
#include "libravatarserv.hpp"
|
||||
|
||||
@ -102,17 +103,49 @@ int main()
|
||||
}
|
||||
else if (avatar.fallback.substr(0, 9) == "identicon")
|
||||
{
|
||||
image = image::identicon(avatar.digest);
|
||||
if (image.error == 0)
|
||||
try
|
||||
{
|
||||
image.image.scale(Magick::Geometry(avatar.size, avatar.size));
|
||||
Identiconpp identicon(4, 4, Identiconpp::identicon_type::simple,
|
||||
"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
|
||||
});
|
||||
Magick::Image img;
|
||||
img = identicon.generate(avatar.digest, avatar.size);
|
||||
image::Image image({ 0, img });
|
||||
image::write(image);
|
||||
}
|
||||
else
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
cout << "Status: 500 Internal Server Error\n\n";
|
||||
cerr << "Error: Couldn't generate identicon.\n";
|
||||
cerr << "Error: Couldn't generate identicon ("
|
||||
<< e.what() << ").\n";
|
||||
}
|
||||
// image = image::identicon(avatar.digest);
|
||||
// // Magick::Image =
|
||||
// if (image.error == 0)
|
||||
// {
|
||||
// image.image.scale(Magick::Geometry(avatar.size, avatar.size));
|
||||
// image::write(image);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cout << "Status: 500 Internal Server Error\n\n";
|
||||
// cerr << "Error: Couldn't generate identicon.\n";
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user