modified scott native to accept arbitrary values
This commit is contained in:
parent
513efc4436
commit
44f8f30ccc
3 changed files with 31 additions and 3 deletions
BIN
assets/images/jjosmap.png
Normal file
BIN
assets/images/jjosmap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
20
commands/image-editing/jjos.js
Normal file
20
commands/image-editing/jjos.js
Normal file
|
@ -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;
|
|
@ -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<string>(Arguments, "basePath");
|
||||
string assetPathIn = GetArgumentWithFallback<string>(Arguments, "assetPath", "assets/images/scott.png");
|
||||
string distortPathIn = GetArgumentWithFallback<string>(Arguments, "distortPath", "assets/images/scottmap.png");
|
||||
|
||||
int compx = GetArgumentWithFallback<int>(Arguments, "compx", 127);
|
||||
int compy = GetArgumentWithFallback<int>(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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue