@crabcrop/url 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explain.js +22 -1
- package/dist/operations.d.ts +4 -0
- package/dist/operations.js +8 -0
- package/package.json +1 -1
package/dist/explain.js
CHANGED
|
@@ -22,6 +22,7 @@ export const FILTER_DESCRIPTIONS = {
|
|
|
22
22
|
pixelatefaces: "pixelate detected faces (needs a face model on the server)",
|
|
23
23
|
blurclass: "blur every detected object of the named class (needs a detection model on the server)",
|
|
24
24
|
pixelateclass: "pixelate every detected object of the named class (needs a detection model on the server)",
|
|
25
|
+
recolorclass: "recolor every detected object of the named class to the given color (needs a detection model on the server)",
|
|
25
26
|
removebg: "remove the background (needs an AI model on the server)",
|
|
26
27
|
keep_profile: "keep the source color profile instead of converting to sRGB",
|
|
27
28
|
upscale: "AI upscale by the given factor (needs an AI model on the server)",
|
|
@@ -48,6 +49,7 @@ export const FILTER_DESCRIPTIONS = {
|
|
|
48
49
|
blur_region: "gaussian-blur the rectangle (x,y,w,h) in pixels at this point in the chain (redaction)",
|
|
49
50
|
overlay: "composite another image over the result: (url,x,y,alpha,blend[,width %]) with blend normal, multiply, screen, or overlay",
|
|
50
51
|
pixelate_region: "pixelate the rectangle (x,y,w,h) in pixels at this point in the chain (redaction)",
|
|
52
|
+
remove_region: "erase the rectangle (x,y,w,h) in pixels at this point in the chain and inpaint it from the surrounding pixels (AI region removal)",
|
|
51
53
|
};
|
|
52
54
|
const MAX_DIMENSION = 16383;
|
|
53
55
|
function parseDimension(part) {
|
|
@@ -313,8 +315,27 @@ function validateFilter(name, args) {
|
|
|
313
315
|
? null
|
|
314
316
|
: bad;
|
|
315
317
|
}
|
|
318
|
+
case "recolorclass": {
|
|
319
|
+
if (args === null)
|
|
320
|
+
return bad;
|
|
321
|
+
const cut = args.lastIndexOf(",");
|
|
322
|
+
if (cut < 0)
|
|
323
|
+
return bad;
|
|
324
|
+
if (!/^[0-9a-fA-F]{6}$/.test(args.slice(cut + 1)))
|
|
325
|
+
return bad;
|
|
326
|
+
const decoded = percentDecodable(args.slice(0, cut));
|
|
327
|
+
if (decoded === null)
|
|
328
|
+
return bad;
|
|
329
|
+
const name = decoded.trim();
|
|
330
|
+
return name.length >= 1 &&
|
|
331
|
+
new TextEncoder().encode(name).length <= 64 &&
|
|
332
|
+
/^[\p{L}\p{N} _.\-/]+$/u.test(name)
|
|
333
|
+
? null
|
|
334
|
+
: bad;
|
|
335
|
+
}
|
|
316
336
|
case "blur_region":
|
|
317
|
-
case "pixelate_region":
|
|
337
|
+
case "pixelate_region":
|
|
338
|
+
case "remove_region": {
|
|
318
339
|
if (args === null)
|
|
319
340
|
return bad;
|
|
320
341
|
const parts = args.split(",");
|
package/dist/operations.d.ts
CHANGED
|
@@ -171,8 +171,12 @@ export declare const filter: {
|
|
|
171
171
|
blurClass(name: string): string;
|
|
172
172
|
/** Pixelate every detected object of the named class. */
|
|
173
173
|
pixelateClass(name: string): string;
|
|
174
|
+
/** Recolor every detected object of the named class to the given RRGGBB color. */
|
|
175
|
+
recolorClass(name: string, color: string): string;
|
|
174
176
|
/** Blur the rectangle (x, y, w, h) in pixels. */
|
|
175
177
|
blurRegion(x: number, y: number, w: number, h: number): string;
|
|
176
178
|
/** Pixelate the rectangle (x, y, w, h) in pixels. */
|
|
177
179
|
pixelateRegion(x: number, y: number, w: number, h: number): string;
|
|
180
|
+
/** Erase the rectangle (x, y, w, h) in pixels and inpaint it (AI). */
|
|
181
|
+
removeRegion(x: number, y: number, w: number, h: number): string;
|
|
178
182
|
};
|
package/dist/operations.js
CHANGED
|
@@ -480,6 +480,10 @@ export const filter = {
|
|
|
480
480
|
pixelateClass(name) {
|
|
481
481
|
return `pixelateclass(${className("pixelateclass name", name)})`;
|
|
482
482
|
},
|
|
483
|
+
/** Recolor every detected object of the named class to the given RRGGBB color. */
|
|
484
|
+
recolorClass(name, color) {
|
|
485
|
+
return `recolorclass(${className("recolorclass name", name)},${hex6("recolorclass color", color)})`;
|
|
486
|
+
},
|
|
483
487
|
/** Blur the rectangle (x, y, w, h) in pixels. */
|
|
484
488
|
blurRegion(x, y, w, h) {
|
|
485
489
|
return `blur_region(${region(x, y, w, h)})`;
|
|
@@ -488,6 +492,10 @@ export const filter = {
|
|
|
488
492
|
pixelateRegion(x, y, w, h) {
|
|
489
493
|
return `pixelate_region(${region(x, y, w, h)})`;
|
|
490
494
|
},
|
|
495
|
+
/** Erase the rectangle (x, y, w, h) in pixels and inpaint it (AI). */
|
|
496
|
+
removeRegion(x, y, w, h) {
|
|
497
|
+
return `remove_region(${region(x, y, w, h)})`;
|
|
498
|
+
},
|
|
491
499
|
};
|
|
492
500
|
function region(x, y, w, h) {
|
|
493
501
|
intIn("region x", x, 0, MAX_DIMENSION);
|