diff --git a/commands/image-editing/speechbubble.js b/commands/image-editing/speechbubble.js index 16a1298..5835692 100644 --- a/commands/image-editing/speechbubble.js +++ b/commands/image-editing/speechbubble.js @@ -1,18 +1,18 @@ import ImageCommand from "../../classes/imageCommand.js"; -class SpeechbubbleCommand extends ImageCommand { - params = { - water: "./assets/images/speechbubble.png", - gravity: "north", - resize: true, - yscale: 0.2, - }; +class SpeechBubbleCommand extends ImageCommand { + params = { + water: "./assets/images/speechbubble.png", + gravity: "north", + resize: true, + yscale: 0.2, + }; - static description = "Adds a speech bubble to the image."; - static aliases = ["speech","speechbubble"]; + static description = "Adds a speech bubble to an image"; + static aliases = ["speech", "sb"]; - static noImage = "You need to provide an image/GIF to add a speech bubble." - static command = "watermark"; + static noImage = "You need to provide an image/GIF to add a speech bubble!"; + static command = "watermark"; } -export default SpeechbubbleCommand; +export default SpeechBubbleCommand; diff --git a/natives/watermark.cc b/natives/watermark.cc index ed78c3f..ebec903 100644 --- a/natives/watermark.cc +++ b/natives/watermark.cc @@ -14,12 +14,14 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) { Napi::Object obj = info[0].As(); Napi::Buffer data = obj.Get("data").As>(); string water = obj.Get("water").As().Utf8Value(); - Magick::GravityType gravity = Magick::GravityType(obj.Get("gravity").As().Int64Value()); + Magick::GravityType gravity = + Magick::GravityType(obj.Get("gravity").As().Int64Value()); bool resize = obj.Has("resize") ? obj.Get("resize").As().Value() : false; float yscale = obj.Has("yscale") - ? obj.Get("yscale").As().FloatValue() : false; + ? obj.Get("yscale").As().FloatValue() + : false; bool append = obj.Has("append") ? obj.Get("append").As().Value() : false; @@ -45,11 +47,12 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) { if (resize && append) { string query(to_string(frames.front().baseColumns()) + "x"); watermark.scale(Geometry(query)); - } else if (resize&&yscale) { - string query(to_string(frames.front().baseColumns())+"x"+to_string(frames.front().baseRows()*yscale)+"!"); - watermark.resize(Geometry(query)); + } else if (resize && yscale) { + string query(to_string(frames.front().baseColumns()) + "x" + + to_string(frames.front().baseRows() * yscale) + "!"); + watermark.resize(Geometry(query)); } else if (resize) { - string query("x"+to_string(frames.front().baseRows())); + string query("x" + to_string(frames.front().baseRows())); watermark.scale(Geometry(query)); } coalesceImages(&coalesced, frames.begin(), frames.end()); @@ -65,12 +68,10 @@ Napi::Value Watermark(const Napi::CallbackInfo &info) { } else if (mc) { image.backgroundColor("white"); image.extent(Geometry(image.columns(), image.rows() + 15)); - image.composite(watermark, gravity, - Magick::OverCompositeOp); + image.composite(watermark, gravity, Magick::OverCompositeOp); final = image; } else { - image.composite(watermark, gravity, - Magick::OverCompositeOp); + image.composite(watermark, gravity, Magick::OverCompositeOp); final = image; } image.magick(type); diff --git a/utils/image-runner.js b/utils/image-runner.js index 197f3f7..a46116f 100644 --- a/utils/image-runner.js +++ b/utils/image-runner.js @@ -7,17 +7,17 @@ const nodeRequire = createRequire(import.meta.url); const magick = nodeRequire(`../build/${process.env.DEBUG && process.env.DEBUG === "true" ? "Debug" : "Release"}/image.node`); const enumMap = { - "forget":0, - "northwest":1, - "north":2, - "northeast":3, - "west":4, - "center":5, - "east":6, - "southwest":7, - "south":8, - "southeast":9 -} + "forget": 0, + "northwest": 1, + "north": 2, + "northeast": 3, + "west": 4, + "center": 5, + "east": 6, + "southwest": 7, + "south": 8, + "southeast": 9 +}; export default function run(object) { return new Promise((resolve, reject) => { @@ -36,10 +36,10 @@ export default function run(object) { const fileExtension = object.params.type ? object.params.type.split("/")[1] : "png"; promise.then(buf => { object.params.data = buf; - const objectWithFixedType = Object.assign({}, object.params, {type: fileExtension}); + const objectWithFixedType = Object.assign({}, object.params, { type: fileExtension }); if (objectWithFixedType.gravity) { - if (isNaN(Number(objectWithFixedType.gravity))){ - objectWithFixedType.gravity=enumMap[objectWithFixedType.gravity]; + if (isNaN(objectWithFixedType.gravity)) { + objectWithFixedType.gravity = enumMap[objectWithFixedType.gravity]; } } try {