From bb966df085222b791277ef997217ff1bc64c9c7e Mon Sep 17 00:00:00 2001 From: Essem Date: Wed, 22 Jun 2022 21:55:09 -0500 Subject: [PATCH] Add flag to flip speech bubble --- commands/image-editing/speechbubble.js | 7 ++++++- natives/watermark.cc | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/commands/image-editing/speechbubble.js b/commands/image-editing/speechbubble.js index b9a3c5b..3bcdaf5 100644 --- a/commands/image-editing/speechbubble.js +++ b/commands/image-editing/speechbubble.js @@ -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; } diff --git a/natives/watermark.cc b/natives/watermark.cc index 7431d67..b2cdec0 100644 --- a/natives/watermark.cc +++ b/natives/watermark.cc @@ -24,6 +24,8 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) { : false; bool alpha = obj.Has("alpha") ? obj.Get("alpha").As().Value() : false; + bool flip = + obj.Has("flip") ? obj.Get("flip").As().Value() : false; bool mc = obj.Has("mc") ? obj.Get("mc").As().Value() : false; string basePath = obj.Get("basePath").As().Utf8Value(); string type = obj.Get("type").As().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) {