@watermarkws/cli 0.1.1 → 0.1.3
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/README.md +1 -1
- package/SKILL.md +4 -4
- package/package.json +1 -1
- package/src/api.js +1 -1
- package/src/cli.js +7 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ watermark image process <source> --op <operation> [--op ...] [--format webp] [--
|
|
|
28
28
|
watermark image read <source> [--level] # --level also finds the angle that levels a tilted horizon
|
|
29
29
|
watermark image create --width 1200 --height 300 --op 'text:text=Hi,font=inter-bold,size=96' --op trim --out logo.png
|
|
30
30
|
watermark video process <source> --op <operation> [--max-duration 30] [--out file]
|
|
31
|
-
watermark video read <source> | watermark video screenshot <source> --seconds 5
|
|
31
|
+
watermark video read <source> | watermark video screenshot <source> --seconds 5 [--auto] # --auto takes another frame when that one is blank
|
|
32
32
|
watermark document process <source> --op <operation> [--max-pages 10] [--out file]
|
|
33
33
|
watermark document read <source> | watermark document snapshot <source> --page 1
|
|
34
34
|
watermark request get <id> | watermark request abort <id>
|
package/SKILL.md
CHANGED
|
@@ -26,7 +26,7 @@ watermark image process photo.jpg --op resize:width=1600,height=1600 --op waterm
|
|
|
26
26
|
watermark image read photo.jpg --json # width, height, format; add --level for the angle that levels the horizon
|
|
27
27
|
watermark image create --width 1200 --height 300 --op 'text:text=Lena Hart,font=inter-bold,size=96,color=#202020,position=center' --op trim --format png --out logo.png
|
|
28
28
|
watermark video process clip.mp4 --op watermark:image_url=https://example.com/logo.png,x=24,y=24 --max-duration 30 --out preview.mp4
|
|
29
|
-
watermark video screenshot clip.mp4 --seconds 5 --format png --out frame.png
|
|
29
|
+
watermark video screenshot clip.mp4 --seconds 5 --auto --format png --out frame.png # --auto: if that frame is blank (black, white, a fade), take one 10% in or the middle
|
|
30
30
|
watermark document process contract.pdf --op watermark:image_url=https://example.com/stamp.png,x=20,y=230 --out contract-stamped.pdf
|
|
31
31
|
watermark document snapshot contract.pdf --page 1 --format png --out page-1.png
|
|
32
32
|
watermark operations image # every operation and parameter, live from the API (also video, document)
|
|
@@ -35,9 +35,9 @@ watermark request get 1234 # follow a request
|
|
|
35
35
|
watermark account # balance and limits
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Useful options on processing commands: `--out <file>` (wait, then download), `--no-wait` (print the queued request and return), `--timeout <seconds>` (default 300), `--format <fmt>`, `--ops-json '[…]'` instead of `--op`, `--max-duration <s>` (video), `--max-pages <n>` (documents), `--customer <id>`, `--metadata key=value`, `--json`.
|
|
38
|
+
Useful options on processing commands: `--out <file>` (wait, then download), `--no-wait` (print the queued request and return), `--timeout <seconds>` (default 300), `--format <fmt>`, `--ops-json '[…]'` instead of `--op`, `--max-duration <s>` (video), `--auto` (video screenshot: pass over a blank frame; `result.data.seconds` says which moment was used), `--max-pages <n>` (documents), `--customer <id>`, `--metadata key=value`, `--json`.
|
|
39
39
|
|
|
40
|
-
Operations that exist: images `resize`, `crop`, `rotate`, `flip`, `grayscale`, `border`, `watermark`, `thumbnail`, `compress`, `sepia`, `exposure`, `filter`, `remove_background`, `orient`, `text`, `trim`, `color`, `frame`, `protect`, `shave`, `line`, `adjust`, `color_profile`; videos `resize`, `crop`, `rotate`, `flip`, `grayscale`, `border`, `watermark`; documents `watermark` only (an image on every page; make a text stamp with `image create` first). `watermark` takes `image_url` or `image` (a `file_…` id), `x`, `y` from the top left, `tile_spacing_x`/`tile_spacing_y` to repeat it
|
|
40
|
+
Operations that exist: images `resize`, `crop`, `rotate`, `flip`, `grayscale`, `border`, `watermark`, `thumbnail`, `compress`, `sepia`, `exposure`, `filter`, `remove_background`, `orient`, `text`, `trim`, `color`, `frame`, `protect`, `shave`, `line`, `adjust`, `color_profile`; videos `resize`, `crop`, `rotate`, `flip`, `grayscale`, `border`, `watermark`; documents `watermark` only (an image on every page; make a text stamp with `image create` first). `watermark` takes `image_url` or `image` (a `file_…` id), `x`, `y` from the top left, `tile_spacing_x`/`tile_spacing_y` to repeat it. Run `watermark operations image` before using a parameter you are not sure of.
|
|
41
41
|
|
|
42
42
|
## A folder of files
|
|
43
43
|
|
|
@@ -81,7 +81,7 @@ A failed request has `"status": "failed"` and `error.code` / `error.message`. An
|
|
|
81
81
|
## Rules
|
|
82
82
|
|
|
83
83
|
- Never paste file contents or base64 into a command; give the path and the CLI uploads it. Never ask the user to host a local file first.
|
|
84
|
-
- Credit is prepaid and every finished request is charged ($0.002 an image, $0.
|
|
84
|
+
- Credit is prepaid and every finished request is charged ($0.002 an image, $0.005 a document page, $0.03 a started minute of video). Before more than about 20 files, a video over about 10 minutes, or a document with hundreds of pages, tell the user the cost and ask.
|
|
85
85
|
- Failed and aborted requests are free; fix the cause (the message names the field) and run again. Rate limits and server errors are retried by the CLI itself.
|
|
86
86
|
- Always pass `--out` when the user wants the file, and `--json` when a script reads the result. Download links in `result.files[].url` last 7 days; `watermark file get <file_id>` gives a fresh one while the file is kept.
|
|
87
87
|
- Video needs a live key on an account that has bought credit; a test key gets `402 paid_account_required`.
|
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// retries for 429 (after Retry-After), 5xx and dropped connections, with an
|
|
3
3
|
// Idempotency-Key on every POST so a retried POST never runs twice.
|
|
4
4
|
|
|
5
|
-
export const VERSION = '0.1.
|
|
5
|
+
export const VERSION = '0.1.3';
|
|
6
6
|
|
|
7
7
|
export class ApiError extends Error {
|
|
8
8
|
constructor(status, error = {}) {
|
package/src/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ Usage:
|
|
|
9
9
|
watermark image create --width 1200 --height 300 [--background "#ffffff"] --op <operation> [--out file]
|
|
10
10
|
watermark video process <source> --op <operation> [--max-duration 30] [--out file]
|
|
11
11
|
watermark video read <source>
|
|
12
|
-
watermark video screenshot <source> --seconds 5 [--format png] [--out file]
|
|
12
|
+
watermark video screenshot <source> --seconds 5 [--auto] [--format png] [--out file]
|
|
13
13
|
watermark document process <source> --op <operation> [--max-pages 10] [--out file]
|
|
14
14
|
watermark document read <source>
|
|
15
15
|
watermark document snapshot <source> [--page 1] [--format png] [--out file]
|
|
@@ -62,7 +62,7 @@ const ACTIONS = {
|
|
|
62
62
|
documents: ['process', 'read', 'snapshot'],
|
|
63
63
|
};
|
|
64
64
|
const REPEATABLE = new Set(['op', 'metadata', 'prefix', 'event']);
|
|
65
|
-
const FLAGS = new Set(['json', 'no-wait', 'help', 'version', 'level']);
|
|
65
|
+
const FLAGS = new Set(['json', 'no-wait', 'help', 'version', 'level', 'auto']);
|
|
66
66
|
|
|
67
67
|
// Parse argv into positionals and options; repeatable options collect arrays.
|
|
68
68
|
export function parseArgs(argv) {
|
|
@@ -286,6 +286,11 @@ async function runMedia(api, media, [action, source], options, { output, print,
|
|
|
286
286
|
body.level = true;
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
if (options.auto) {
|
|
290
|
+
if (media !== 'videos' || action !== 'screenshot') throw new UsageError('--auto is for watermark video screenshot.');
|
|
291
|
+
body.auto = true;
|
|
292
|
+
}
|
|
293
|
+
|
|
289
294
|
if (action === 'process' || action === 'create') {
|
|
290
295
|
const operations = options['ops-json'] ? JSON.parse(options['ops-json']) : options.op.map(parseOperation);
|
|
291
296
|
if (operations.length === 0) throw new UsageError('Give at least one --op (see: watermark operations).');
|