Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../src",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.cts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/commonjs"
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"extends": "./build.json",
|
||||
"include": [
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.mts",
|
||||
"../src/**/*.tsx",
|
||||
"../src/**/*.json"
|
||||
],
|
||||
"exclude": [
|
||||
"../**/*.test.ts",
|
||||
"../src/package.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "../.tshy-build/esm"
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/plugin-threshold@1.5.0 build /Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold
|
||||
> tshy
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
> @jimp/plugin-threshold@1.1.2 lint /Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold
|
||||
> eslint .
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
|
||||
> @jimp/plugin-threshold@1.1.1 test:browser /Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold
|
||||
> vitest --config vitest.config.browser.mjs "--watch=false" "--u"
|
||||
|
||||
|
||||
[7m[1m[36m RUN [39m[22m[27m [36mv1.4.0[39m [90m/Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold[39m
|
||||
[2m[32m Browser runner started at http://localhost:5173/[39m[22m
|
||||
|
||||
[?25l [90m·[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[90m·[39m Threshold[2m (1)[22m
|
||||
[90m·[39m defines default threshold for lighter backgrounds
|
||||
[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠏[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠋[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠏[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠋[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [90m·[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[90m·[39m Threshold[2m (1)[22m
|
||||
[90m·[39m defines default threshold for lighter backgrounds
|
||||
[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠏[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠋[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m[33m 420[2mms[22m[39m
|
||||
[32m✓[39m Threshold[2m (1)[22m[33m 420[2mms[22m[39m
|
||||
[32m✓[39m defines default threshold for lighter backgrounds[33m 420[2mms[22m[39m
|
||||
[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m[33m 420[2mms[22m[39m
|
||||
[32m✓[39m Threshold[2m (1)[22m[33m 420[2mms[22m[39m
|
||||
[32m✓[39m defines default threshold for lighter backgrounds[33m 420[2mms[22m[39m
|
||||
|
||||
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Tests [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Start at [22m 00:42:21
|
||||
[2m Duration [22m 1.81s[2m (transform 0ms, setup 0ms, collect 59ms, tests 420ms, environment 0ms, prepare 0ms)[22m
|
||||
|
||||
[?25h[?25h
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
|
||||
|
||||
> @jimp/plugin-threshold@1.1.2 test /Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold
|
||||
> vitest "--watch=false" "-u"
|
||||
|
||||
|
||||
[7m[1m[36m RUN [39m[22m[27m [36mv2.0.5[39m [90m/Users/andrewlisowski/Documents/jimp/plugins/plugin-threshold[39m
|
||||
|
||||
[?25l [90m·[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[90m·[39m Threshold[2m (1)[22m
|
||||
[90m·[39m defines default threshold for lighter backgrounds
|
||||
[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠏[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠋[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠏[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠋[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠙[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠹[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠸[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠼[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠴[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠦[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠧[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [33m❯[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m
|
||||
[33m❯[39m Threshold[2m (1)[22m
|
||||
[33m⠇[39m defines default threshold for lighter backgrounds
|
||||
[?25l[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m[33m 651[2mms[22m[39m
|
||||
[32m✓[39m Threshold[2m (1)[22m[33m 651[2mms[22m[39m
|
||||
[32m✓[39m defines default threshold for lighter backgrounds[33m 650[2mms[22m[39m
|
||||
[2K[1A[2K[1A[2K[1A[2K[G [32m✓[39m [2msrc/[22mindex[2m.test.ts[22m[2m (1)[22m[33m 651[2mms[22m[39m
|
||||
[32m✓[39m Threshold[2m (1)[22m[33m 651[2mms[22m[39m
|
||||
[32m✓[39m defines default threshold for lighter backgrounds[33m 650[2mms[22m[39m
|
||||
|
||||
[2m Test Files [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Tests [22m [1m[32m1 passed[39m[22m[90m (1)[39m
|
||||
[2m Start at [22m 01:23:31
|
||||
[2m Duration [22m 1.36s[2m (transform 157ms, setup 0ms, collect 243ms, tests 651ms, environment 0ms, prepare 88ms)[22m
|
||||
|
||||
[?25h[?25h
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
# v1.1.3 (Mon Sep 02 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.1.0 (Sun Sep 01 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.3 (Sat Aug 31 2024)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
---
|
||||
|
||||
# v1.0.2 (Sat Aug 31 2024)
|
||||
|
||||
#### ⚠️ Pushed to `main`
|
||||
|
||||
- set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
- add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Oliver Moran
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<div align="center">
|
||||
<img width="200" height="200"
|
||||
src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
|
||||
<h1>@jimp/plugin-threshold</h1>
|
||||
<p>Lightens an image.</p>
|
||||
</div>
|
||||
|
||||
This is useful as a simplified method for processing scanned drawings, signatures, etc
|
||||
|
||||
- [threshold](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#threshold)
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { z } from "zod";
|
||||
declare const ThresholdOptionsSchema: z.ZodObject<{
|
||||
/** A number auto limited between 0 - 255 */
|
||||
max: z.ZodNumber;
|
||||
/** A number auto limited between 0 - 255 (default 255) */
|
||||
replace: z.ZodOptional<z.ZodNumber>;
|
||||
/** A boolean whether to apply greyscale beforehand (default true) */
|
||||
autoGreyscale: z.ZodOptional<z.ZodBoolean>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
max: number;
|
||||
replace?: number | undefined;
|
||||
autoGreyscale?: boolean | undefined;
|
||||
}, {
|
||||
max: number;
|
||||
replace?: number | undefined;
|
||||
autoGreyscale?: boolean | undefined;
|
||||
}>;
|
||||
export type ThresholdOptions = z.infer<typeof ThresholdOptionsSchema>;
|
||||
export declare const methods: {
|
||||
/**
|
||||
* Applies a minimum color threshold to a grayscale image.
|
||||
* Converts image to grayscale by default.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.threshold({ max: 150 });
|
||||
* ```
|
||||
*/
|
||||
threshold<I extends JimpClass>(image: I, options: ThresholdOptions): I;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,sBAAsB;IAC1B,4CAA4C;;IAE5C,2DAA2D;;IAE3D,sEAAsE;;;;;;;;;;EAEtE,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;OAWG;cACO,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,gBAAgB;CA0BnE,CAAC"}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.methods = void 0;
|
||||
const utils_1 = require("@jimp/utils");
|
||||
const plugin_color_1 = require("@jimp/plugin-color");
|
||||
const zod_1 = require("zod");
|
||||
const ThresholdOptionsSchema = zod_1.z.object({
|
||||
/** A number auto limited between 0 - 255 */
|
||||
max: zod_1.z.number().min(0).max(255),
|
||||
/** A number auto limited between 0 - 255 (default 255) */
|
||||
replace: zod_1.z.number().min(0).max(255).optional(),
|
||||
/** A boolean whether to apply greyscale beforehand (default true) */
|
||||
autoGreyscale: zod_1.z.boolean().optional(),
|
||||
});
|
||||
exports.methods = {
|
||||
/**
|
||||
* Applies a minimum color threshold to a grayscale image.
|
||||
* Converts image to grayscale by default.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.threshold({ max: 150 });
|
||||
* ```
|
||||
*/
|
||||
threshold(image, options) {
|
||||
let { max, replace = 255,
|
||||
// eslint-disable-next-line prefer-const
|
||||
autoGreyscale = true, } = ThresholdOptionsSchema.parse(options);
|
||||
max = (0, utils_1.limit255)(max);
|
||||
replace = (0, utils_1.limit255)(replace);
|
||||
if (autoGreyscale) {
|
||||
plugin_color_1.methods.greyscale(image);
|
||||
}
|
||||
image.scan((_, __, idx) => {
|
||||
const grey = image.bitmap.data[idx] < max ? image.bitmap.data[idx] : replace;
|
||||
image.bitmap.data[idx] = grey;
|
||||
image.bitmap.data[idx + 1] = grey;
|
||||
image.bitmap.data[idx + 2] = grey;
|
||||
});
|
||||
return image;
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,qDAAsD;AACtD,6BAAwB;AAExB,MAAM,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,4CAA4C;IAC5C,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/B,2DAA2D;IAC3D,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC9C,sEAAsE;IACtE,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAIU,QAAA,OAAO,GAAG;IACrB;;;;;;;;;;;OAWG;IACH,SAAS,CAAsB,KAAQ,EAAE,OAAyB;QAChE,IAAI,EACF,GAAG,EACH,OAAO,GAAG,GAAG;QACb,wCAAwC;QACxC,aAAa,GAAG,IAAI,GACrB,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE1C,GAAG,GAAG,IAAA,gBAAQ,EAAC,GAAG,CAAC,CAAC;QACpB,OAAO,GAAG,IAAA,gBAAQ,EAAC,OAAO,CAAC,CAAC;QAE5B,IAAI,aAAa,EAAE,CAAC;YAClB,sBAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACxB,MAAM,IAAI,GACR,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAE,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAEpE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAC9B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;YAClC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { z } from "zod";
|
||||
declare const ThresholdOptionsSchema: z.ZodObject<{
|
||||
/** A number auto limited between 0 - 255 */
|
||||
max: z.ZodNumber;
|
||||
/** A number auto limited between 0 - 255 (default 255) */
|
||||
replace: z.ZodOptional<z.ZodNumber>;
|
||||
/** A boolean whether to apply greyscale beforehand (default true) */
|
||||
autoGreyscale: z.ZodOptional<z.ZodBoolean>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
max: number;
|
||||
replace?: number | undefined;
|
||||
autoGreyscale?: boolean | undefined;
|
||||
}, {
|
||||
max: number;
|
||||
replace?: number | undefined;
|
||||
autoGreyscale?: boolean | undefined;
|
||||
}>;
|
||||
export type ThresholdOptions = z.infer<typeof ThresholdOptionsSchema>;
|
||||
export declare const methods: {
|
||||
/**
|
||||
* Applies a minimum color threshold to a grayscale image.
|
||||
* Converts image to grayscale by default.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.threshold({ max: 150 });
|
||||
* ```
|
||||
*/
|
||||
threshold<I extends JimpClass>(image: I, options: ThresholdOptions): I;
|
||||
};
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,sBAAsB;IAC1B,4CAA4C;;IAE5C,2DAA2D;;IAE3D,sEAAsE;;;;;;;;;;EAEtE,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;OAWG;cACO,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,gBAAgB;CA0BnE,CAAC"}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { limit255 } from "@jimp/utils";
|
||||
import { methods as color } from "@jimp/plugin-color";
|
||||
import { z } from "zod";
|
||||
const ThresholdOptionsSchema = z.object({
|
||||
/** A number auto limited between 0 - 255 */
|
||||
max: z.number().min(0).max(255),
|
||||
/** A number auto limited between 0 - 255 (default 255) */
|
||||
replace: z.number().min(0).max(255).optional(),
|
||||
/** A boolean whether to apply greyscale beforehand (default true) */
|
||||
autoGreyscale: z.boolean().optional(),
|
||||
});
|
||||
export const methods = {
|
||||
/**
|
||||
* Applies a minimum color threshold to a grayscale image.
|
||||
* Converts image to grayscale by default.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.threshold({ max: 150 });
|
||||
* ```
|
||||
*/
|
||||
threshold(image, options) {
|
||||
let { max, replace = 255,
|
||||
// eslint-disable-next-line prefer-const
|
||||
autoGreyscale = true, } = ThresholdOptionsSchema.parse(options);
|
||||
max = limit255(max);
|
||||
replace = limit255(replace);
|
||||
if (autoGreyscale) {
|
||||
color.greyscale(image);
|
||||
}
|
||||
image.scan((_, __, idx) => {
|
||||
const grey = image.bitmap.data[idx] < max ? image.bitmap.data[idx] : replace;
|
||||
image.bitmap.data[idx] = grey;
|
||||
image.bitmap.data[idx + 1] = grey;
|
||||
image.bitmap.data[idx + 2] = grey;
|
||||
});
|
||||
return image;
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,4CAA4C;IAC5C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC/B,2DAA2D;IAC3D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC9C,sEAAsE;IACtE,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACtC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB;;;;;;;;;;;OAWG;IACH,SAAS,CAAsB,KAAQ,EAAE,OAAyB;QAChE,IAAI,EACF,GAAG,EACH,OAAO,GAAG,GAAG;QACb,wCAAwC;QACxC,aAAa,GAAG,IAAI,GACrB,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAE1C,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACpB,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE5B,IAAI,aAAa,EAAE,CAAC;YAClB,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE;YACxB,MAAM,IAAI,GACR,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAE,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAEpE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;YAC9B,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;YAClC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import shared from "@jimp/config-eslint/base.js";
|
||||
export default [...shared];
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "@jimp/plugin-threshold",
|
||||
"version": "1.6.0",
|
||||
"repository": "jimp-dev/jimp",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "vitest",
|
||||
"test:browser": "vitest --config vitest.config.browser.mjs",
|
||||
"build": "tshy",
|
||||
"dev": "tshy --watch",
|
||||
"clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
|
||||
},
|
||||
"author": "Andrew Lisowski <lisowski54@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@jimp/config-eslint": "1.6.0",
|
||||
"@jimp/config-typescript": "1.6.0",
|
||||
"@jimp/config-vitest": "1.6.0",
|
||||
"@jimp/js-jpeg": "1.6.0",
|
||||
"@jimp/test-utils": "1.6.0",
|
||||
"@vitest/browser": "^2.0.5",
|
||||
"eslint": "^9.9.1",
|
||||
"tshy": "^3.0.2",
|
||||
"typescript": "^5.5.4",
|
||||
"vite-plugin-node-polyfills": "^0.22.0",
|
||||
"vitest": "^2.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jimp/core": "1.6.0",
|
||||
"@jimp/plugin-color": "1.6.0",
|
||||
"@jimp/plugin-hash": "1.6.0",
|
||||
"@jimp/types": "1.6.0",
|
||||
"@jimp/utils": "1.6.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"tshy": {
|
||||
"exclude": [
|
||||
"**/*.test.ts"
|
||||
],
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"module": "./dist/esm/index.js",
|
||||
"gitHead": "c88abe6046dccbdb6e4f5f00c3dd403c81d83515"
|
||||
}
|
||||
Generated
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 431 KiB |
+23
@@ -0,0 +1,23 @@
|
||||
import { expect, test, describe } from "vitest";
|
||||
import "@jimp/test-utils";
|
||||
|
||||
import jpeg from "@jimp/js-jpeg";
|
||||
import { methods as hash } from "@jimp/plugin-hash";
|
||||
import { createJimp } from "@jimp/core";
|
||||
|
||||
import { methods as threshold } from "./index.js";
|
||||
import { getTestImagePath } from "@jimp/test-utils";
|
||||
|
||||
const jimp = createJimp({ formats: [jpeg], plugins: [threshold, hash] });
|
||||
|
||||
describe("Threshold", () => {
|
||||
test("defines default threshold for lighter backgrounds", async () => {
|
||||
const testImage = await jimp.read(getTestImagePath("hands.jpg"));
|
||||
const expectedImage = await jimp.read(
|
||||
getTestImagePath("hands_mx200_rp255.jpg"),
|
||||
);
|
||||
const output = testImage.threshold({ max: 200, replace: 255 }).hash();
|
||||
|
||||
expect(output).toStrictEqual(expectedImage.hash());
|
||||
});
|
||||
});
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { JimpClass } from "@jimp/types";
|
||||
import { limit255 } from "@jimp/utils";
|
||||
import { methods as color } from "@jimp/plugin-color";
|
||||
import { z } from "zod";
|
||||
|
||||
const ThresholdOptionsSchema = z.object({
|
||||
/** A number auto limited between 0 - 255 */
|
||||
max: z.number().min(0).max(255),
|
||||
/** A number auto limited between 0 - 255 (default 255) */
|
||||
replace: z.number().min(0).max(255).optional(),
|
||||
/** A boolean whether to apply greyscale beforehand (default true) */
|
||||
autoGreyscale: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type ThresholdOptions = z.infer<typeof ThresholdOptionsSchema>;
|
||||
|
||||
export const methods = {
|
||||
/**
|
||||
* Applies a minimum color threshold to a grayscale image.
|
||||
* Converts image to grayscale by default.
|
||||
* @example
|
||||
* ```ts
|
||||
* import { Jimp } from "jimp";
|
||||
*
|
||||
* const image = await Jimp.read("test/image.png");
|
||||
*
|
||||
* image.threshold({ max: 150 });
|
||||
* ```
|
||||
*/
|
||||
threshold<I extends JimpClass>(image: I, options: ThresholdOptions) {
|
||||
let {
|
||||
max,
|
||||
replace = 255,
|
||||
// eslint-disable-next-line prefer-const
|
||||
autoGreyscale = true,
|
||||
} = ThresholdOptionsSchema.parse(options);
|
||||
|
||||
max = limit255(max);
|
||||
replace = limit255(replace);
|
||||
|
||||
if (autoGreyscale) {
|
||||
color.greyscale(image);
|
||||
}
|
||||
|
||||
image.scan((_, __, idx) => {
|
||||
const grey =
|
||||
image.bitmap.data[idx]! < max ? image.bitmap.data[idx]! : replace;
|
||||
|
||||
image.bitmap.data[idx] = grey;
|
||||
image.bitmap.data[idx + 1] = grey;
|
||||
image.bitmap.data[idx + 2] = grey;
|
||||
});
|
||||
|
||||
return image;
|
||||
},
|
||||
};
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "@jimp/config-typescript/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import config from "@jimp/config-vitest/browser";
|
||||
|
||||
export default config;
|
||||
Reference in new issue
Block a user