diff --git a/assets/images/jjosmap.png b/assets/images/jjosmap.png new file mode 100644 index 0000000..0c0392e Binary files /dev/null and b/assets/images/jjosmap.png differ diff --git a/commands/image-editing/jjos.js b/commands/image-editing/jjos.js new file mode 100644 index 0000000..773932b --- /dev/null +++ b/commands/image-editing/jjos.js @@ -0,0 +1,20 @@ +import ImageCommand from "../../classes/imageCommand.js"; + +class ScottCommand extends ImageCommand { + static category = "image-editing" + static description = "JJoS an image"; + + params = { + assetPath: "assets/images/jjos.png", + distortPath: "assets/images/jjosmap.png", + compx: 261, + compy: 126 + }; + + static aliases = ["woz", "tv", "porn"]; + + static noImage = "You need to provide an image/GIF to JJoS!"; + static command = "scott"; +} + +export default ScottCommand; diff --git a/natives/scott.cc b/natives/scott.cc index 500858d..ac708d9 100644 --- a/natives/scott.cc +++ b/natives/scott.cc @@ -8,6 +8,11 @@ using namespace vips; ArgumentMap Scott(string type, string *outType, char *BufferData, size_t BufferLength, ArgumentMap Arguments, size_t *DataSize) { string basePath = GetArgument(Arguments, "basePath"); + string assetPathIn = GetArgumentWithFallback(Arguments, "assetPath", "assets/images/scott.png"); + string distortPathIn = GetArgumentWithFallback(Arguments, "distortPath", "assets/images/scottmap.png"); + + int compx = GetArgumentWithFallback(Arguments, "compx", 127); + int compy = GetArgumentWithFallback(Arguments, "compy", 181); VOption *options = VImage::option()->set("access", "sequential"); @@ -21,10 +26,13 @@ ArgumentMap Scott(string type, string *outType, char *BufferData, size_t BufferL int pageHeight = vips_image_get_page_height(in.get_image()); int nPages = vips_image_get_n_pages(in.get_image()); - string assetPath = basePath + "assets/images/scott.png"; + string assetPath = basePath + assetPathIn; VImage bg = VImage::new_from_file(assetPath.c_str()); - string distortPath = basePath + "assets/images/scottmap.png"; + int bgwidth = bg.width(); + int bgpageHeight = vips_image_get_page_height(bg.get_image()); + + string distortPath = basePath + distortPathIn; VImage distort = VImage::new_from_file(distortPath.c_str()); VImage distortImage = @@ -40,7 +48,7 @@ ArgumentMap Scott(string type, string *outType, char *BufferData, size_t BufferL VImage mapped = resized.mapim(distortImage) .extract_band(0, VImage::option()->set("n", 3)) .bandjoin(distort[2]); - VImage offset = mapped.embed(127, 181, 864, 481); + VImage offset = mapped.embed(compx, compy, bgwidth, bgpageHeight); VImage composited = bg.composite2(offset, VIPS_BLEND_MODE_OVER); img.push_back(composited); }