Deduplicate vips shutdown, reformat natives, remove soos alias
This commit is contained in:
parent
5d8974d177
commit
3c16599126
81 changed files with 360 additions and 464 deletions
1
.clang-format
Normal file
1
.clang-format
Normal file
|
@ -0,0 +1 @@
|
||||||
|
BasedOnStyle: google
|
|
@ -6,7 +6,7 @@ class SooSCommand extends ImageCommand {
|
||||||
};
|
};
|
||||||
|
|
||||||
static description = "\"Loops\" an image sequence by reversing it when it's finished";
|
static description = "\"Loops\" an image sequence by reversing it when it's finished";
|
||||||
static aliases = ["bounce", "boomerang"];
|
static aliases = ["boomerang"];
|
||||||
|
|
||||||
static requiresGIF = true;
|
static requiresGIF = true;
|
||||||
static noImage = "You need to provide an image/GIF to loop!";
|
static noImage = "You need to provide an image/GIF to loop!";
|
||||||
|
|
|
@ -195,6 +195,7 @@
|
||||||
"Pizza Tower",
|
"Pizza Tower",
|
||||||
"ANTONBLAST",
|
"ANTONBLAST",
|
||||||
"[object Object]",
|
"[object Object]",
|
||||||
|
"Xonotic",
|
||||||
"The clock is ticking."
|
"The clock is ticking."
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ char *Blur(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
// TODO: find a better way to calculate the intensity for GIFs without
|
// TODO: find a better way to calculate the intensity for GIFs without
|
||||||
// splitting frames
|
// splitting frames
|
||||||
|
@ -28,8 +27,5 @@ char *Blur(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Blur(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Blur(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,14 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Bounce(string *type, char *BufferData, size_t BufferLength,
|
char *Bounce(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option();
|
VOption *options = VImage::option();
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -17,8 +17,7 @@ char *Bounce(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
||||||
: options)
|
: options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -31,7 +30,8 @@ char *Bounce(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage img_frame =
|
VImage img_frame =
|
||||||
*type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
|
*type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
|
||||||
double height = halfHeight * ((abs(sin(i * mult)) * -1) + 1);
|
double height = halfHeight * ((abs(sin(i * mult)) * -1) + 1);
|
||||||
VImage embedded = img_frame.embed(0, height, width, pageHeight + halfHeight);
|
VImage embedded =
|
||||||
|
img_frame.embed(0, height, width, pageHeight + halfHeight);
|
||||||
img.push_back(embedded);
|
img.push_back(embedded);
|
||||||
}
|
}
|
||||||
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
VImage final = VImage::arrayjoin(img, VImage::option()->set("across", 1));
|
||||||
|
@ -46,7 +46,5 @@ char *Bounce(string *type, char *BufferData, size_t BufferLength,
|
||||||
|
|
||||||
*type = "gif";
|
*type = "gif";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Bounce(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Bounce(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,15 +1,13 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Caption(string *type, char *BufferData, size_t BufferLength,
|
char *Caption(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string caption = GetArgument<string>(Arguments, "caption");
|
string caption = GetArgument<string>(Arguments, "caption");
|
||||||
string font = GetArgument<string>(Arguments, "font");
|
string font = GetArgument<string>(Arguments, "font");
|
||||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||||
|
@ -21,8 +19,7 @@ char *Caption(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int size = width / 10;
|
int size = width / 10;
|
||||||
|
@ -75,8 +72,5 @@ char *Caption(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Caption(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Caption(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,15 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *CaptionTwo(string *type, char *BufferData, size_t BufferLength,
|
char *CaptionTwo(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
bool top = GetArgument<bool>(Arguments, "top");
|
bool top = GetArgument<bool>(Arguments, "top");
|
||||||
string caption = GetArgument<string>(Arguments, "caption");
|
string caption = GetArgument<string>(Arguments, "caption");
|
||||||
string font = GetArgument<string>(Arguments, "font");
|
string font = GetArgument<string>(Arguments, "font");
|
||||||
|
@ -22,8 +21,7 @@ char *CaptionTwo(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int size = width / 13;
|
int size = width / 13;
|
||||||
|
@ -78,8 +76,5 @@ char *CaptionTwo(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* CaptionTwo(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* CaptionTwo(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,4 +1,3 @@
|
||||||
#include "common.h"
|
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -7,12 +6,13 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
char *Circle(string *type, char *BufferData, size_t BufferLength,
|
char *Circle(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Circle(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Circle(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,9 +1,9 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ VImage sepia = VImage::new_matrixv(3, 3, 0.3588, 0.7044, 0.1368, 0.2990, 0.5870,
|
||||||
|
|
||||||
char *Colors(string *type, char *BufferData, size_t BufferLength,
|
char *Colors(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string color = GetArgument<string>(Arguments, "color");
|
string color = GetArgument<string>(Arguments, "color");
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
@ -33,8 +32,5 @@ char *Colors(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Colors(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Colors(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <variant>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::variant;
|
using std::variant;
|
||||||
using std::map;
|
|
||||||
|
|
||||||
typedef variant<string, float, bool, int> ArgumentVariant;
|
typedef variant<string, float, bool, int> ArgumentVariant;
|
||||||
typedef map<string, ArgumentVariant> ArgumentMap;
|
typedef map<string, ArgumentVariant> ArgumentMap;
|
||||||
|
@ -31,13 +31,15 @@ T GetArgumentWithFallback(ArgumentMap map, string key, T fallback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAP_HAS(ARRAY, KEY) (ARRAY.count(KEY) > 0)
|
#define MAP_HAS(ARRAY, KEY) (ARRAY.count(KEY) > 0)
|
||||||
#define MAP_GET(ARRAY, KEY, TYPE) (MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) : NULL) // C++ has forced my hand
|
#define MAP_GET(ARRAY, KEY, TYPE) \
|
||||||
#define MAP_GET_FALLBACK(ARRAY, KEY, TYPE, FALLBACK) (MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) : FALLBACK)
|
(MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) \
|
||||||
|
: NULL) // C++ has forced my hand
|
||||||
|
#define MAP_GET_FALLBACK(ARRAY, KEY, TYPE, FALLBACK) \
|
||||||
|
(MAP_HAS(ARRAY, KEY) ? get<TYPE>(ARRAY.at(KEY)) : FALLBACK)
|
||||||
|
|
||||||
#define ARG_TYPES std::variant<string, bool, int, float>
|
#define ARG_TYPES std::variant<string, bool, int, float>
|
||||||
|
|
||||||
const std::unordered_map<std::string, std::string> fontPaths {
|
const std::unordered_map<std::string, std::string> fontPaths{
|
||||||
{"futura", "assets/fonts/caption.otf"},
|
{"futura", "assets/fonts/caption.otf"},
|
||||||
{"helvetica", "assets/fonts/caption2.ttf"},
|
{"helvetica", "assets/fonts/caption2.ttf"},
|
||||||
{"roboto", "assets/fonts/reddit.ttf"}
|
{"roboto", "assets/fonts/reddit.ttf"}};
|
||||||
};
|
|
|
@ -1,14 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Crop(string *type, char *BufferData, size_t BufferLength,
|
char *Crop(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -46,8 +46,5 @@ char *Crop(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Crop(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Crop(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,13 @@
|
||||||
#include "common.h"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Deepfry(string *type, char *BufferData, size_t BufferLength,
|
char *Deepfry(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -15,8 +15,7 @@ char *Deepfry(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -49,16 +48,13 @@ char *Deepfry(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::option()->set("Q", 1)->set("strip", true));
|
VImage::option()->set("Q", 1)->set("strip", true));
|
||||||
final = VImage::new_from_buffer(jpgBuf, jpgLength, "");
|
final = VImage::new_from_buffer(jpgBuf, jpgLength, "");
|
||||||
final.set(VIPS_META_PAGE_HEIGHT, pageHeight);
|
final.set(VIPS_META_PAGE_HEIGHT, pageHeight);
|
||||||
if (*type == "gif")
|
if (*type == "gif") final.set("delay", fried.get_array_int("delay"));
|
||||||
final.set("delay", fried.get_array_int("delay"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize,
|
final.write_to_buffer(
|
||||||
|
("." + *type).c_str(), &buf, DataSize,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0) : 0);
|
*type == "gif" ? VImage::option()->set("dither", 0) : 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Deepfry(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Deepfry(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Explode(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Explode(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,15 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Flag(string *type, char *BufferData, size_t BufferLength,
|
char *Flag(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string overlay = GetArgument<string>(Arguments, "overlay");
|
string overlay = GetArgument<string>(Arguments, "overlay");
|
||||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||||
|
|
||||||
|
@ -20,8 +19,7 @@ char *Flag(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
|
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -31,8 +29,8 @@ char *Flag(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage overlayInput = VImage::new_from_file(assetPath.c_str());
|
VImage overlayInput = VImage::new_from_file(assetPath.c_str());
|
||||||
VImage overlayImage = overlayInput.resize(
|
VImage overlayImage = overlayInput.resize(
|
||||||
(double)width / (double)overlayInput.width(),
|
(double)width / (double)overlayInput.width(),
|
||||||
VImage::option()->set("vscale", (double)pageHeight /
|
VImage::option()->set(
|
||||||
(double)overlayInput.height()));
|
"vscale", (double)pageHeight / (double)overlayInput.height()));
|
||||||
if (!overlayImage.has_alpha()) {
|
if (!overlayImage.has_alpha()) {
|
||||||
overlayImage = overlayImage.bandjoin(127);
|
overlayImage = overlayImage.bandjoin(127);
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,7 +56,5 @@ char *Flag(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Flag(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Flag(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,15 +1,13 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Flip(string *type, char *BufferData, size_t BufferLength,
|
char *Flip(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
bool flop = GetArgument<bool>(Arguments, "flop");
|
bool flop = GetArgument<bool>(Arguments, "flop");
|
||||||
|
|
||||||
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
|
@ -18,8 +16,7 @@ char *Flip(string *type, char *BufferData, size_t BufferLength,
|
||||||
"access", "sequential")
|
"access", "sequential")
|
||||||
: 0)
|
: 0)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
VImage out;
|
VImage out;
|
||||||
if (flop) {
|
if (flop) {
|
||||||
|
@ -46,7 +43,5 @@ char *Flip(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Flip(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Flip(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,16 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Freeze(string *type, char *BufferData, size_t BufferLength,
|
char *Freeze(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
bool loop = GetArgumentWithFallback<bool>(Arguments, "loop", false);
|
bool loop = GetArgumentWithFallback<bool>(Arguments, "loop", false);
|
||||||
int frame = GetArgumentWithFallback<int>(Arguments, "frame", -1);
|
int frame = GetArgumentWithFallback<int>(Arguments, "frame", -1);
|
||||||
|
|
||||||
|
@ -42,22 +40,17 @@ char *Freeze(string *type, char *BufferData, size_t BufferLength,
|
||||||
*DataSize = BufferLength + 19;
|
*DataSize = BufferLength + 19;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (none)
|
if (none) *DataSize = BufferLength;
|
||||||
*DataSize = BufferLength;
|
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return newData;
|
return newData;
|
||||||
} else if (frame >= 0 && !loop) {
|
} else if (frame >= 0 && !loop) {
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in = VImage::new_from_buffer(
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
int nPages = vips_image_get_n_pages(in.get_image());
|
int nPages = vips_image_get_n_pages(in.get_image());
|
||||||
|
@ -69,9 +62,6 @@ char *Freeze(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
} else {
|
} else {
|
||||||
lastPos = (char *)memchr(fileData, '\x21', BufferLength);
|
lastPos = (char *)memchr(fileData, '\x21', BufferLength);
|
||||||
|
@ -86,11 +76,8 @@ char *Freeze(string *type, char *BufferData, size_t BufferLength,
|
||||||
none = false;
|
none = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (none)
|
if (none) *DataSize = BufferLength;
|
||||||
*DataSize = BufferLength;
|
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Freeze(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Freeze(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,12 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Gamexplain(string *type, char *BufferData, size_t BufferLength,
|
char *Gamexplain(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
@ -16,8 +15,7 @@ char *Gamexplain(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
string assetPath = basePath + "assets/images/gamexplain.png";
|
string assetPath = basePath + "assets/images/gamexplain.png";
|
||||||
VImage tmpl = VImage::new_from_file(assetPath.c_str());
|
VImage tmpl = VImage::new_from_file(assetPath.c_str());
|
||||||
|
@ -47,8 +45,5 @@ char *Gamexplain(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Gamexplain(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Gamexplain(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,12 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Globe(string *type, char *BufferData, size_t BufferLength,
|
char *Globe(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||||
|
|
||||||
VOption *options = VImage::option();
|
VOption *options = VImage::option();
|
||||||
|
@ -18,8 +17,7 @@ char *Globe(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
||||||
: options)
|
: options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -28,17 +26,15 @@ char *Globe(string *type, char *BufferData, size_t BufferLength,
|
||||||
double size = min(width, pageHeight);
|
double size = min(width, pageHeight);
|
||||||
|
|
||||||
string diffPath = basePath + "assets/images/globediffuse.png";
|
string diffPath = basePath + "assets/images/globediffuse.png";
|
||||||
VImage diffuse =
|
VImage diffuse = VImage::new_from_file(diffPath.c_str())
|
||||||
VImage::new_from_file(diffPath.c_str())
|
.resize(size / 500.0, VImage::option()->set(
|
||||||
.resize(size / 500.0,
|
"kernel", VIPS_KERNEL_CUBIC)) /
|
||||||
VImage::option()->set("kernel", VIPS_KERNEL_CUBIC)) /
|
|
||||||
255;
|
255;
|
||||||
|
|
||||||
string specPath = basePath + "assets/images/globespec.png";
|
string specPath = basePath + "assets/images/globespec.png";
|
||||||
VImage specular =
|
VImage specular = VImage::new_from_file(specPath.c_str())
|
||||||
VImage::new_from_file(specPath.c_str())
|
.resize(size / 500.0, VImage::option()->set(
|
||||||
.resize(size / 500.0,
|
"kernel", VIPS_KERNEL_CUBIC));
|
||||||
VImage::option()->set("kernel", VIPS_KERNEL_CUBIC));
|
|
||||||
|
|
||||||
string distortPath = basePath + "assets/images/spheremap.png";
|
string distortPath = basePath + "assets/images/spheremap.png";
|
||||||
VImage distort =
|
VImage distort =
|
||||||
|
@ -73,7 +69,5 @@ char *Globe(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(".gif", &buf, DataSize);
|
final.write_to_buffer(".gif", &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Globe(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Globe(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -34,7 +34,5 @@ char *Homebrew(string *type, ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
*type = "png";
|
*type = "png";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Homebrew(string *type, ArgumentMap Arguments, size_t *DataSize);
|
char *Homebrew(string *type, ArgumentMap Arguments, size_t *DataSize);
|
|
@ -1,16 +1,16 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <napi.h>
|
#include <napi.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "blur.h"
|
#include "blur.h"
|
||||||
#include "bounce.h"
|
#include "bounce.h"
|
||||||
#include "colors.h"
|
|
||||||
#include "caption.h"
|
#include "caption.h"
|
||||||
#include "caption2.h"
|
#include "caption2.h"
|
||||||
#include "circle.h"
|
#include "circle.h"
|
||||||
|
#include "colors.h"
|
||||||
|
#include "common.h"
|
||||||
#include "crop.h"
|
#include "crop.h"
|
||||||
#include "deepfry.h"
|
#include "deepfry.h"
|
||||||
#include "explode.h"
|
#include "explode.h"
|
||||||
|
@ -25,7 +25,6 @@
|
||||||
#include "magik.h"
|
#include "magik.h"
|
||||||
#include "meme.h"
|
#include "meme.h"
|
||||||
#include "mirror.h"
|
#include "mirror.h"
|
||||||
#include "swirl.h"
|
|
||||||
#include "motivate.h"
|
#include "motivate.h"
|
||||||
#include "reddit.h"
|
#include "reddit.h"
|
||||||
#include "resize.h"
|
#include "resize.h"
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
#include "speed.h"
|
#include "speed.h"
|
||||||
#include "spin.h"
|
#include "spin.h"
|
||||||
#include "squish.h"
|
#include "squish.h"
|
||||||
|
#include "swirl.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "togif.h"
|
#include "togif.h"
|
||||||
#include "uncanny.h"
|
#include "uncanny.h"
|
||||||
|
@ -52,8 +52,10 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
std::map<std::string, char* (*)(string *type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize)> FunctionMap = {
|
std::map<std::string,
|
||||||
{"blur", &Blur},
|
char* (*)(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize)>
|
||||||
|
FunctionMap = {{"blur", &Blur},
|
||||||
{"bounce", &Bounce},
|
{"bounce", &Bounce},
|
||||||
{"caption", &Caption},
|
{"caption", &Caption},
|
||||||
{"captionTwo", &CaptionTwo},
|
{"captionTwo", &CaptionTwo},
|
||||||
|
@ -89,13 +91,11 @@ std::map<std::string, char* (*)(string *type, char* BufferData, size_t BufferLen
|
||||||
{"wall", Wall},
|
{"wall", Wall},
|
||||||
{"watermark", &Watermark},
|
{"watermark", &Watermark},
|
||||||
{"whisper", Whisper},
|
{"whisper", Whisper},
|
||||||
{"zamn", Zamn}
|
{"zamn", Zamn}};
|
||||||
};
|
|
||||||
|
|
||||||
std::map<std::string, char* (*)(string *type, ArgumentMap Arguments, size_t* DataSize)> NoInputFunctionMap = {
|
std::map<std::string,
|
||||||
{"homebrew", Homebrew},
|
char* (*)(string* type, ArgumentMap Arguments, size_t* DataSize)>
|
||||||
{"sonic", Sonic}
|
NoInputFunctionMap = {{"homebrew", Homebrew}, {"sonic", Sonic}};
|
||||||
};
|
|
||||||
|
|
||||||
bool isNapiValueInt(Napi::Env& env, Napi::Value& num) {
|
bool isNapiValueInt(Napi::Env& env, Napi::Value& num) {
|
||||||
return env.Global()
|
return env.Global()
|
||||||
|
@ -108,21 +108,23 @@ bool isNapiValueInt(Napi::Env& env, Napi::Value& num) {
|
||||||
.Value();
|
.Value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Napi::Value ProcessImage(const Napi::CallbackInfo &info) {
|
Napi::Value ProcessImage(const Napi::CallbackInfo& info) {
|
||||||
Napi::Env env = info.Env();
|
Napi::Env env = info.Env();
|
||||||
Napi::Object result = Napi::Object::New(env);
|
Napi::Object result = Napi::Object::New(env);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
string command = info[0].As<Napi::String>().Utf8Value();
|
string command = info[0].As<Napi::String>().Utf8Value();
|
||||||
Napi::Object obj = info[1].As<Napi::Object>();
|
Napi::Object obj = info[1].As<Napi::Object>();
|
||||||
string type = obj.Has("type") ? obj.Get("type").As<Napi::String>().Utf8Value() : NULL;
|
string type =
|
||||||
|
obj.Has("type") ? obj.Get("type").As<Napi::String>().Utf8Value() : NULL;
|
||||||
|
|
||||||
Napi::Array properties = obj.GetPropertyNames();
|
Napi::Array properties = obj.GetPropertyNames();
|
||||||
|
|
||||||
ArgumentMap Arguments;
|
ArgumentMap Arguments;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < properties.Length(); i++) {
|
for (unsigned int i = 0; i < properties.Length(); i++) {
|
||||||
string property = properties.Get(uint32_t(i)).As<Napi::String>().Utf8Value();
|
string property =
|
||||||
|
properties.Get(uint32_t(i)).As<Napi::String>().Utf8Value();
|
||||||
|
|
||||||
if (property == "data") {
|
if (property == "data") {
|
||||||
continue;
|
continue;
|
||||||
|
@ -142,23 +144,30 @@ Napi::Value ProcessImage(const Napi::CallbackInfo &info) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw "Unimplemented value type passed to image native.";
|
throw "Unimplemented value type passed to image native.";
|
||||||
//Arguments[property] = val;
|
// Arguments[property] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length = 0;
|
size_t length = 0;
|
||||||
char* buf;
|
char* buf;
|
||||||
if (obj.Has("data")) {
|
if (obj.Has("data")) {
|
||||||
Napi::Buffer<char> data = obj.Has("data") ? obj.Get("data").As<Napi::Buffer<char>>() : Napi::Buffer<char>::New(env, 0);
|
Napi::Buffer<char> data = obj.Has("data")
|
||||||
buf = FunctionMap.at(command)(&type, data.Data(), data.Length(), Arguments, &length);
|
? obj.Get("data").As<Napi::Buffer<char>>()
|
||||||
|
: Napi::Buffer<char>::New(env, 0);
|
||||||
|
buf = FunctionMap.at(command)(&type, data.Data(), data.Length(),
|
||||||
|
Arguments, &length);
|
||||||
} else {
|
} else {
|
||||||
buf = NoInputFunctionMap.at(command)(&type, Arguments, &length);
|
buf = NoInputFunctionMap.at(command)(&type, Arguments, &length);
|
||||||
}
|
}
|
||||||
result.Set("data", Napi::Buffer<char>::New(env, buf, length, [](Napi::Env env, void* data) {
|
|
||||||
free(data);
|
vips_error_clear();
|
||||||
}));
|
vips_thread_shutdown();
|
||||||
|
|
||||||
|
result.Set("data", Napi::Buffer<char>::New(
|
||||||
|
env, buf, length,
|
||||||
|
[](Napi::Env env, void* data) { free(data); }));
|
||||||
result.Set("type", type);
|
result.Set("type", type);
|
||||||
} catch (std::exception const &err) {
|
} catch (std::exception const& err) {
|
||||||
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
Napi::Error::New(env, err.what()).ThrowAsJavaScriptException();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
Napi::Error::New(env, "Unknown error").ThrowAsJavaScriptException();
|
||||||
|
@ -167,22 +176,22 @@ Napi::Value ProcessImage(const Napi::CallbackInfo &info) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Napi::Object Init(Napi::Env env, Napi::Object exports){
|
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Magick::InitializeMagick("");
|
Magick::InitializeMagick("");
|
||||||
#endif
|
#endif
|
||||||
if (vips_init(""))
|
if (vips_init("")) vips_error_exit(NULL);
|
||||||
vips_error_exit(NULL);
|
exports.Set(Napi::String::New(env, "image"),
|
||||||
exports.Set(Napi::String::New(env, "image"), Napi::Function::New(env, ProcessImage)); // new function handler
|
Napi::Function::New(env, ProcessImage)); // new function handler
|
||||||
|
|
||||||
Napi::Array arr = Napi::Array::New(env);
|
Napi::Array arr = Napi::Array::New(env);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (auto const& imap: FunctionMap) {
|
for (auto const& imap : FunctionMap) {
|
||||||
Napi::HandleScope scope(env);
|
Napi::HandleScope scope(env);
|
||||||
arr[i] = Napi::String::New(env, imap.first);
|
arr[i] = Napi::String::New(env, imap.first);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
for (auto const& imap: NoInputFunctionMap) {
|
for (auto const& imap : NoInputFunctionMap) {
|
||||||
Napi::HandleScope scope(env);
|
Napi::HandleScope scope(env);
|
||||||
arr[i] = Napi::String::New(env, imap.first);
|
arr[i] = Napi::String::New(env, imap.first);
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Invert(string *type, char *BufferData, size_t BufferLength,
|
char *Invert(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
VImage noAlpha =
|
VImage noAlpha =
|
||||||
in.extract_band(0, VImage::option()->set("n", in.bands() - 1));
|
in.extract_band(0, VImage::option()->set("n", in.bands() - 1));
|
||||||
|
@ -25,7 +23,5 @@ char *Invert(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Invert(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Invert(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ char *Jpeg(string *type, char *BufferData, size_t BufferLength,
|
||||||
BufferData, BufferLength, "",
|
BufferData, BufferLength, "",
|
||||||
VImage::option()->set("access", "sequential")->set("n", -1))
|
VImage::option()->set("access", "sequential")->set("n", -1))
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -53,18 +52,15 @@ char *Jpeg(string *type, char *BufferData, size_t BufferLength,
|
||||||
final.set("delay", in.get_array_int("delay"));
|
final.set("delay", in.get_array_int("delay"));
|
||||||
}
|
}
|
||||||
|
|
||||||
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize,
|
final.write_to_buffer(
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)
|
("." + *type).c_str(), &buf, DataSize,
|
||||||
: 0);
|
*type == "gif" ? VImage::option()->set("dither", 0) : 0);
|
||||||
} else {
|
} else {
|
||||||
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "");
|
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "");
|
||||||
in.write_to_buffer(".jpg", &buf, DataSize,
|
in.write_to_buffer(".jpg", &buf, DataSize,
|
||||||
VImage::option()->set("Q", quality)->set("strip", true));
|
VImage::option()->set("Q", quality)->set("strip", true));
|
||||||
|
|
||||||
*type = "jpg";
|
*type = "jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Jpeg(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Jpeg(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,16 +1,16 @@
|
||||||
#include "common.h"
|
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
char *Magik(string *type, char *BufferData, size_t BufferLength,
|
char *Magik(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Magik(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Magik(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ char *Meme(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -101,10 +100,9 @@ char *Meme(string *type, char *BufferData, size_t BufferLength,
|
||||||
}
|
}
|
||||||
bottomOutline = (bottomOutline == zeroVec);
|
bottomOutline = (bottomOutline == zeroVec);
|
||||||
VImage bottomInvert = bottomOutline.extract_band(3).invert();
|
VImage bottomInvert = bottomOutline.extract_band(3).invert();
|
||||||
bottomOutline =
|
bottomOutline = bottomOutline
|
||||||
bottomOutline
|
.extract_band(0, VImage::option()->set(
|
||||||
.extract_band(0,
|
"n", bottomOutline.bands() - 1))
|
||||||
VImage::option()->set("n", bottomOutline.bands() - 1))
|
|
||||||
.bandjoin(bottomInvert);
|
.bandjoin(bottomInvert);
|
||||||
bottomText = bottomOutline.composite2(bottomIn, VIPS_BLEND_MODE_OVER);
|
bottomText = bottomOutline.composite2(bottomIn, VIPS_BLEND_MODE_OVER);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +134,5 @@ char *Meme(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Meme(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Meme(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ char *Mirror(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
VImage out;
|
VImage out;
|
||||||
|
|
||||||
|
@ -61,7 +60,5 @@ char *Mirror(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Mirror(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Mirror(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ char *Motivate(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int size = width / 5;
|
int size = width / 5;
|
||||||
|
@ -100,8 +99,7 @@ char *Motivate(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::option()->set("background", 0x000000)->set("expand", true));
|
VImage::option()->set("background", 0x000000)->set("expand", true));
|
||||||
}
|
}
|
||||||
if (bottom_text != "") {
|
if (bottom_text != "") {
|
||||||
if (top_text == "")
|
if (top_text == "") frame = bordered3;
|
||||||
frame = bordered3;
|
|
||||||
frame = frame.join(
|
frame = frame.join(
|
||||||
bottomImage.gravity(VIPS_COMPASS_DIRECTION_NORTH, bordered3.width(),
|
bottomImage.gravity(VIPS_COMPASS_DIRECTION_NORTH, bordered3.width(),
|
||||||
bottomImage.height() + (size / 4),
|
bottomImage.height() + (size / 4),
|
||||||
|
@ -117,10 +115,9 @@ char *Motivate(string *type, char *BufferData, size_t BufferLength,
|
||||||
final.set(VIPS_META_PAGE_HEIGHT, height);
|
final.set(VIPS_META_PAGE_HEIGHT, height);
|
||||||
|
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize,
|
final.write_to_buffer(
|
||||||
|
("." + *type).c_str(), &buf, DataSize,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 1) : 0);
|
*type == "gif" ? VImage::option()->set("dither", 1) : 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Motivate(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Motivate(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,12 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Reddit(string *type, char *BufferData, size_t BufferLength,
|
char *Reddit(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string text = GetArgument<string>(Arguments, "text");
|
string text = GetArgument<string>(Arguments, "text");
|
||||||
string basePath = GetArgument<string>(Arguments, "basePath");
|
string basePath = GetArgument<string>(Arguments, "basePath");
|
||||||
|
|
||||||
|
@ -17,8 +16,7 @@ char *Reddit(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
string assetPath = basePath + "assets/images/reddit.png";
|
string assetPath = basePath + "assets/images/reddit.png";
|
||||||
VImage tmpl = VImage::new_from_file(assetPath.c_str());
|
VImage tmpl = VImage::new_from_file(assetPath.c_str());
|
||||||
|
@ -64,7 +62,5 @@ char *Reddit(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Reddit(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Reddit(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -50,7 +50,5 @@ char *Resize(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
out.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Resize(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Resize(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,8 +1,8 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -55,7 +55,5 @@ char *Reverse(string *type, char *BufferData, size_t BufferLength,
|
||||||
|
|
||||||
*type = "gif";
|
*type = "gif";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Reverse(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Reverse(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,10 +1,11 @@
|
||||||
#include "common.h"
|
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Scott(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Scott(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -17,8 +17,7 @@ char *Snapchat(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -68,7 +67,5 @@ char *Snapchat(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Snapchat(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Snapchat(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -32,7 +32,5 @@ char *Sonic(string *type, ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
*type = "png";
|
*type = "png";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Sonic(string *type, ArgumentMap Arguments, size_t *DataSize);
|
char *Sonic(string *type, ArgumentMap Arguments, size_t *DataSize);
|
|
@ -1,18 +1,16 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
void *memset16(void *m, uint16_t val, size_t count) {
|
void *memset16(void *m, uint16_t val, size_t count) {
|
||||||
uint16_t *buf = (uint16_t *)m;
|
uint16_t *buf = (uint16_t *)m;
|
||||||
|
|
||||||
while (count--)
|
while (count--) *buf++ = val;
|
||||||
*buf++ = val;
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +19,7 @@ char *vipsRemove(char *data, size_t length, size_t *DataSize, int speed) {
|
||||||
|
|
||||||
VImage in = VImage::new_from_buffer(data, length, "", options->set("n", -1))
|
VImage in = VImage::new_from_buffer(data, length, "", options->set("n", -1))
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -44,7 +41,6 @@ char *vipsRemove(char *data, size_t length, size_t *DataSize, int speed) {
|
||||||
|
|
||||||
char *Speed(string *type, char *BufferData, size_t BufferLength,
|
char *Speed(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
bool slow = GetArgumentWithFallback<bool>(Arguments, "slow", false);
|
bool slow = GetArgumentWithFallback<bool>(Arguments, "slow", false);
|
||||||
int speed = GetArgumentWithFallback<int>(Arguments, "speed", 2);
|
int speed = GetArgumentWithFallback<int>(Arguments, "speed", 2);
|
||||||
|
|
||||||
|
@ -102,8 +98,5 @@ char *Speed(string *type, char *BufferData, size_t BufferLength,
|
||||||
*DataSize = BufferLength;
|
*DataSize = BufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
|
|
||||||
return fileData;
|
return fileData;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Speed(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Speed(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Spin(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Spin(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,14 +1,14 @@
|
||||||
#include "common.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Squish(string *type, char *BufferData, size_t BufferLength,
|
char *Squish(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option();
|
VOption *options = VImage::option();
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
|
@ -17,8 +17,7 @@ char *Squish(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
||||||
: options)
|
: options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -48,7 +47,5 @@ char *Squish(string *type, char *BufferData, size_t BufferLength,
|
||||||
|
|
||||||
*type = "gif";
|
*type = "gif";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Squish(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Squish(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,21 +1,19 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Swirl(string *type, char *BufferData, size_t BufferLength,
|
char *Swirl(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in =
|
VImage in =
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
int nPages = vips_image_get_n_pages(in.get_image());
|
int nPages = vips_image_get_n_pages(in.get_image());
|
||||||
|
@ -74,7 +72,5 @@ char *Swirl(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(".gif", &buf, DataSize);
|
final.write_to_buffer(".gif", &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Swirl(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Swirl(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,16 +1,16 @@
|
||||||
#include "common.h"
|
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
char *Tile(string *type, char *BufferData, size_t BufferLength,
|
char *Tile(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Tile(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Tile(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,32 +1,26 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *ToGif(string *type, char *BufferData, size_t BufferLength,
|
char *ToGif(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
if (*type == "gif") {
|
if (*type == "gif") {
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
*DataSize = BufferLength;
|
*DataSize = BufferLength;
|
||||||
return BufferData;
|
return BufferData;
|
||||||
} else {
|
} else {
|
||||||
VOption *options = VImage::option()->set("access", "sequential");
|
VOption *options = VImage::option()->set("access", "sequential");
|
||||||
|
|
||||||
VImage in = VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage in = VImage::new_from_buffer(
|
||||||
*type == "webp" ? options->set("n", -1)
|
BufferData, BufferLength, "",
|
||||||
: options);
|
*type == "webp" ? options->set("n", -1) : options);
|
||||||
|
|
||||||
void *buf;
|
void *buf;
|
||||||
in.write_to_buffer(".gif", &buf, DataSize);
|
in.write_to_buffer(".gif", &buf, DataSize);
|
||||||
|
|
||||||
*type = "gif";
|
*type = "gif";
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* ToGif(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* ToGif(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,13 +1,12 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Uncanny(string *type, char *BufferData, size_t BufferLength,
|
char *Uncanny(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string caption = GetArgument<string>(Arguments, "caption");
|
string caption = GetArgument<string>(Arguments, "caption");
|
||||||
string caption2 = GetArgument<string>(Arguments, "caption2");
|
string caption2 = GetArgument<string>(Arguments, "caption2");
|
||||||
string font = GetArgument<string>(Arguments, "font");
|
string font = GetArgument<string>(Arguments, "font");
|
||||||
|
@ -94,11 +93,9 @@ char *Uncanny(string *type, char *BufferData, size_t BufferLength,
|
||||||
final.set(VIPS_META_PAGE_HEIGHT, 720);
|
final.set(VIPS_META_PAGE_HEIGHT, 720);
|
||||||
|
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize,
|
final.write_to_buffer(
|
||||||
*type == "gif" ? VImage::option()->set("reoptimise", 1)
|
("." + *type).c_str(), &buf, DataSize,
|
||||||
: 0);
|
*type == "gif" ? VImage::option()->set("reoptimise", 1) : 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Uncanny(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Uncanny(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,14 +1,13 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Uncaption(string *type, char *BufferData, size_t BufferLength,
|
char *Uncaption(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
float tolerance = GetArgumentWithFallback<float>(Arguments, "tolerance", 0.5);
|
float tolerance = GetArgumentWithFallback<float>(Arguments, "tolerance", 0.5);
|
||||||
|
|
||||||
VOption *options = VImage::option();
|
VOption *options = VImage::option();
|
||||||
|
@ -19,8 +18,7 @@ char *Uncaption(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
*type == "gif" ? options->set("n", -1)->set("access", "sequential")
|
||||||
: options)
|
: options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -51,7 +49,5 @@ char *Uncaption(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Uncaption(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Uncaption(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,16 +1,16 @@
|
||||||
#include "common.h"
|
|
||||||
#include <Magick++.h>
|
#include <Magick++.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Magick;
|
using namespace Magick;
|
||||||
|
|
||||||
char *Wall(string *type, char *BufferData, size_t BufferLength,
|
char *Wall(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
Blob blob;
|
Blob blob;
|
||||||
|
|
||||||
list<Image> frames;
|
list<Image> frames;
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Wall(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Wall(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,14 +1,13 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
char *Watermark(string *type, char *BufferData, size_t BufferLength,
|
char *Watermark(string *type, char *BufferData, size_t BufferLength,
|
||||||
ArgumentMap Arguments, size_t *DataSize) {
|
ArgumentMap Arguments, size_t *DataSize) {
|
||||||
|
|
||||||
string water = GetArgument<string>(Arguments, "water");
|
string water = GetArgument<string>(Arguments, "water");
|
||||||
int gravity = GetArgument<int>(Arguments, "gravity");
|
int gravity = GetArgument<int>(Arguments, "gravity");
|
||||||
|
|
||||||
|
@ -31,8 +30,7 @@ char *Watermark(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
string merged = basePath + water;
|
string merged = basePath + water;
|
||||||
VImage watermark = VImage::new_from_file(merged.c_str());
|
VImage watermark = VImage::new_from_file(merged.c_str());
|
||||||
|
@ -151,7 +149,5 @@ char *Watermark(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
using std::map;
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Watermark(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Watermark(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ char *Whisper(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -82,7 +81,5 @@ char *Whisper(string *type, char *BufferData, size_t BufferLength,
|
||||||
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
*type == "gif" ? VImage::option()->set("dither", 0)->set("reoptimise", 1)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Whisper(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Whisper(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
|
@ -1,7 +1,7 @@
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <vips/vips8>
|
#include <vips/vips8>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vips;
|
using namespace vips;
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@ char *Zamn(string *type, char *BufferData, size_t BufferLength,
|
||||||
VImage::new_from_buffer(BufferData, BufferLength, "",
|
VImage::new_from_buffer(BufferData, BufferLength, "",
|
||||||
*type == "gif" ? options->set("n", -1) : options)
|
*type == "gif" ? options->set("n", -1) : options)
|
||||||
.colourspace(VIPS_INTERPRETATION_sRGB);
|
.colourspace(VIPS_INTERPRETATION_sRGB);
|
||||||
if (!in.has_alpha())
|
if (!in.has_alpha()) in = in.bandjoin(255);
|
||||||
in = in.bandjoin(255);
|
|
||||||
|
|
||||||
int width = in.width();
|
int width = in.width();
|
||||||
int pageHeight = vips_image_get_page_height(in.get_image());
|
int pageHeight = vips_image_get_page_height(in.get_image());
|
||||||
|
@ -29,12 +28,12 @@ char *Zamn(string *type, char *BufferData, size_t BufferLength,
|
||||||
for (int i = 0; i < nPages; i++) {
|
for (int i = 0; i < nPages; i++) {
|
||||||
VImage img_frame =
|
VImage img_frame =
|
||||||
*type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
|
*type == "gif" ? in.crop(0, i * pageHeight, width, pageHeight) : in;
|
||||||
VImage composited =
|
VImage composited = tmpl.insert(
|
||||||
tmpl.insert(img_frame.extract_band(0, VImage::option()->set("n", 3))
|
img_frame.extract_band(0, VImage::option()->set("n", 3))
|
||||||
.bandjoin(255)
|
.bandjoin(255)
|
||||||
.resize(303.0 / (double)width,
|
.resize(
|
||||||
VImage::option()->set(
|
303.0 / (double)width,
|
||||||
"vscale", 438.0 / (double)pageHeight)),
|
VImage::option()->set("vscale", 438.0 / (double)pageHeight)),
|
||||||
310, 76);
|
310, 76);
|
||||||
img.push_back(composited);
|
img.push_back(composited);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +43,5 @@ char *Zamn(string *type, char *BufferData, size_t BufferLength,
|
||||||
void *buf;
|
void *buf;
|
||||||
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
final.write_to_buffer(("." + *type).c_str(), &buf, DataSize);
|
||||||
|
|
||||||
vips_error_clear();
|
|
||||||
vips_thread_shutdown();
|
|
||||||
return (char *)buf;
|
return (char *)buf;
|
||||||
}
|
}
|
|
@ -4,4 +4,5 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
char* Zamn(string* type, char* BufferData, size_t BufferLength, ArgumentMap Arguments, size_t* DataSize);
|
char* Zamn(string* type, char* BufferData, size_t BufferLength,
|
||||||
|
ArgumentMap Arguments, size_t* DataSize);
|
Loading…
Reference in a new issue