Added tolerance option to uncaption, fixed nogif return type
This commit is contained in:
parent
a82ae115f8
commit
ec6fb7de37
4 changed files with 19 additions and 3 deletions
|
@ -13,6 +13,7 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
try {
|
||||
Napi::Object obj = info[0].As<Napi::Object>();
|
||||
Napi::Buffer<char> data = obj.Get("data").As<Napi::Buffer<char>>();
|
||||
float tolerance = obj.Has("tolerance") ? obj.Get("tolerance").As<Napi::Number>().FloatValue() : 0.95;
|
||||
string type = obj.Get("type").As<Napi::String>().Utf8Value();
|
||||
int delay =
|
||||
obj.Has("delay") ? obj.Get("delay").As<Napi::Number>().Int32Value() : 0;
|
||||
|
@ -37,7 +38,7 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
ssize_t row;
|
||||
for (row = 0; row < rows; ++row) {
|
||||
ColorGray color = firstImage.pixelColor(0, row);
|
||||
if (color.shade() < 0.95) {
|
||||
if (color.shade() < tolerance) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -74,4 +75,4 @@ Napi::Value Uncaption(const Napi::CallbackInfo &info) {
|
|||
} catch (...) {
|
||||
throw Napi::Error::New(env, "Unknown error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue