Add flag to flip speech bubble

This commit is contained in:
Essem 2022-06-22 21:55:09 -05:00
parent b298656515
commit bb966df085
No known key found for this signature in database
GPG Key ID: 7D497397CC3A2A8C
2 changed files with 12 additions and 1 deletions

View File

@ -7,7 +7,8 @@ class SpeechBubbleCommand extends ImageCommand {
gravity: "north",
resize: true,
yscale: 0.2,
alpha: this.specialArgs.alpha
alpha: this.specialArgs.alpha,
flip: this.specialArgs.flip
};
}
@ -17,6 +18,10 @@ class SpeechBubbleCommand extends ImageCommand {
name: "alpha",
description: "Make the top of the speech bubble transparent",
type: 5
}, {
name: "flip",
description: "Flips the speech bubble",
type: 5
});
return this;
}

View File

@ -24,6 +24,8 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
: false;
bool alpha =
obj.Has("alpha") ? obj.Get("alpha").As<Napi::Boolean>().Value() : false;
bool flip =
obj.Has("flip") ? obj.Get("flip").As<Napi::Boolean>().Value() : false;
bool mc = obj.Has("mc") ? obj.Get("mc").As<Napi::Boolean>().Value() : false;
string basePath = obj.Get("basePath").As<Napi::String>().Utf8Value();
string type = obj.Get("type").As<Napi::String>().Utf8Value();
@ -43,6 +45,10 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) {
int pageHeight = vips_image_get_page_height(in.get_image());
int nPages = vips_image_get_n_pages(in.get_image());
if (flip) {
watermark = watermark.flip(VIPS_DIRECTION_HORIZONTAL);
}
if (resize && append) {
watermark = watermark.resize((double)width / (double)watermark.width());
} else if (resize && yscale) {