Added extra font support to some other commands, handle overflow on image api
This commit is contained in:
parent
2644ce2d4a
commit
30bcb7a969
9 changed files with 44 additions and 11 deletions
|
@ -15,6 +15,7 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string caption = obj.Get("caption").As<Napi::String>().Utf8Value();
|
||||
bool top = obj.Get("top").As<Napi::Boolean>().Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
@ -39,7 +40,10 @@ Napi::Value CaptionTwo(const Napi::CallbackInfo &info) {
|
|||
caption_image.fillColor("black");
|
||||
caption_image.font("Helvetica Neue");
|
||||
caption_image.fontPointsize(width / 17);
|
||||
caption_image.read("pango:" + caption);
|
||||
caption_image.read("pango:<span font_family=\"" +
|
||||
(font == "roboto" ? "Roboto Condensed" : font) +
|
||||
"\" weight=\"" + (font != "impact" ? "bold" : "normal") +
|
||||
"\">" + caption + "</span>");
|
||||
caption_image.extent(Geometry(width, caption_image.rows() + (width / 25)),
|
||||
Magick::CenterGravity);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string top = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||
string bottom = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
@ -43,7 +44,10 @@ Napi::Value Meme(const Napi::CallbackInfo &info) {
|
|||
top_text.font("Impact");
|
||||
top_text.fontPointsize(width / 12);
|
||||
top_text.textGravity(Magick::CenterGravity);
|
||||
top_text.read("pango:<span foreground='white'>" + top + "</span>");
|
||||
top_text.read("pango:<span font_family=\"" +
|
||||
(font == "roboto" ? "Roboto Condensed" : font) +
|
||||
"\" weight=\"" + (font != "impact" ? "bold" : "normal") +
|
||||
"\" foreground='white'>" + top + "</span>");
|
||||
Image top_text_fill = top_text;
|
||||
top_text_fill.channel(Magick::AlphaChannel);
|
||||
top_text_fill.morphology(Magick::EdgeOutMorphology, "Octagon");
|
||||
|
|
|
@ -15,6 +15,7 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
string top_text = obj.Get("top").As<Napi::String>().Utf8Value();
|
||||
string bottom_text = obj.Get("bottom").As<Napi::String>().Utf8Value();
|
||||
string font = obj.Get("font").As<Napi::String>().Utf8Value();
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
@ -40,7 +41,10 @@ Napi::Value Motivate(const Napi::CallbackInfo &info) {
|
|||
top.font("Times");
|
||||
top.textGravity(Magick::CenterGravity);
|
||||
top.fontPointsize(56);
|
||||
top.read("pango:<span foreground='white'>" + top_text + "</span>");
|
||||
top.read("pango:<span font_family=\"" +
|
||||
(font == "roboto" ? "Roboto Condensed" : font) +
|
||||
"\" weight=\"" + (font != "impact" ? "bold" : "normal") +
|
||||
"\" foreground='white'>" + top_text + "</span>");
|
||||
top.extent(Geometry(bottom_text != "" ? to_string(top.columns()) + "x" +
|
||||
to_string(top.rows())
|
||||
: to_string(top.columns()) + "x" +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue