@imagerry/cli 0.1.5-beta

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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Imagerry Proprietary License
2
+ Copyright (c) Imagerry. All rights reserved.
3
+
4
+ This software is a commercial product. Use of this software requires a valid,
5
+ purchased license key from imagerry.com.
6
+
7
+ For full terms of service, please visit: https://imagerry.com/legal
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # Imagerry CLI (Beta)
2
+
3
+ The official command-line interface for [Imagerry](https://imagerry.com), built for automating image processing and styling directly from your terminal.
4
+
5
+ > [!NOTE]
6
+ > **Beta Release**
7
+ >
8
+ > Imagerry CLI is currently in beta. At this time, it only supports the **image customizer** mode with basic styling capabilities.
9
+
10
+ > [!IMPORTANT]
11
+ > **Privacy-first processing**
12
+ >
13
+ > Imagerry CLI processes images **locally on your computer** using a blazing-fast native graphics engine. Your images are **never uploaded to Imagerry or any external image-processing server**.
14
+ >
15
+ > A network connection is only used when required to verify your Imagerry Pro license.
16
+
17
+ ## Features
18
+
19
+ * 🖥️ Process images directly from the terminal
20
+ * 🌐 **New:** Host a self-hosted API server with `serve`
21
+ * 🔒 Keep image processing completely local
22
+ * 🎨 Apply built-in styling presets
23
+ * ⚙️ Create and reuse custom JSON presets
24
+ * 🤖 Use in scripts, Docker, and CI/CD workflows
25
+ * 📦 Automate workflows with GitHub Actions
26
+
27
+ ## Installation
28
+
29
+ Install Imagerry CLI globally using npm:
30
+
31
+ ```bash
32
+ npm install -g @imagerry/cli
33
+ ```
34
+
35
+ Verify the installation:
36
+
37
+ ```bash
38
+ imagerry -h
39
+ ```
40
+
41
+ ## Licensing
42
+
43
+ Imagerry CLI requires an **Imagerry Pro** license.
44
+
45
+ You can provide your license key in either of the following ways.
46
+
47
+ ### Command-line option
48
+
49
+ ```bash
50
+ imagerry --input=input.png --output=output.png --license-key=YOUR_KEY
51
+ ```
52
+
53
+ ### Environment variable
54
+
55
+ For automation and CI/CD environments, using an environment variable is recommended:
56
+
57
+ ```bash
58
+ export IMAGERRY_LICENSE_KEY="YOUR_KEY"
59
+ ```
60
+
61
+ > [!TIP]
62
+ > The CLI verifies your license with the payment server, but CLI usage does **not count against your device limit**. This makes it suitable for automated environments such as GitHub Actions, Docker, and CI/CD pipelines.
63
+
64
+ ## Usage
65
+
66
+ ### Basic usage
67
+
68
+ Process an image using the default settings:
69
+
70
+ ```bash
71
+ imagerry --input=input.png --output=output.png
72
+ ```
73
+
74
+ You can also use the shorter argument aliases:
75
+
76
+ ```bash
77
+ imagerry -i input.png -o output.png
78
+ ```
79
+
80
+ ## Built-in Presets
81
+
82
+ To view a full list of available built-in styles and their descriptions, run:
83
+
84
+ ```bash
85
+ imagerry --list-presets
86
+ ```
87
+
88
+ Once you've found a style you like, you can apply it using the `--preset` flag:
89
+
90
+ ```bash
91
+ imagerry --input=input.png --output=output.png --preset=mesh
92
+ ```
93
+
94
+ ## Custom JSON Presets
95
+
96
+ For more control over the output, Imagerry supports custom JSON presets.
97
+
98
+ ### 1. Export a preset template
99
+
100
+ Generate a starting configuration:
101
+
102
+ ```bash
103
+ imagerry --export-preset-template=my-style.json
104
+ ```
105
+
106
+ Edit `my-style.json` with your preferred settings.
107
+
108
+ ### 2. Apply a preset file
109
+
110
+ ```bash
111
+ imagerry \
112
+ -i input.png \
113
+ -o output.png \
114
+ -m image-customizer \
115
+ --preset my-style.json
116
+ ```
117
+
118
+ ### 3. Pass JSON directly
119
+
120
+ For simple configurations, you can provide the preset directly from the terminal:
121
+
122
+ ```bash
123
+ imagerry \
124
+ -i input.png \
125
+ -o output.png \
126
+ -m image-customizer \
127
+ --preset '{"padding": 64, "bgColor": "#000000"}'
128
+ ```
129
+
130
+ This can be useful for scripts where creating a separate preset file would add unnecessary complexity.
131
+
132
+ ## Command Reference
133
+
134
+ To view all available commands, options, and examples:
135
+
136
+ ```bash
137
+ imagerry -h
138
+ ```
139
+
140
+ ## API Server
141
+
142
+ Imagerry CLI includes a built-in Express server that allows you to self-host the engine as a REST API. You can host this on Railway, Render, or any VPS.
143
+
144
+ To start the API server:
145
+
146
+ ```bash
147
+ imagerry serve --port 5273
148
+ ```
149
+ *(Note: A valid `IMAGERRY_LICENSE_KEY` environment variable or `--license-key` flag is required to start the server).*
150
+
151
+ ### API Example
152
+
153
+ Send a `multipart/form-data` POST request to process an image instantly over HTTP:
154
+
155
+ ```bash
156
+ curl -f -X POST http://localhost:5273/api/v1/process \
157
+ -F "image=@/path/to/your/input.png" \
158
+ -F 'preset={"padding": 64, "bgColor": "#18181b"}' \
159
+ --output result.png
160
+ ```
161
+
162
+ > [!WARNING]
163
+ > We strongly recommend including the `-f` (or `--fail-with-body`) flag when using `curl` with `--output`. If the API returns an error, this flag prevents `curl` from saving the JSON error response directly into your output image file, which would result in a corrupted image.
164
+
165
+ ### Built-in API Reference
166
+
167
+ Once the server is running, visit **`http://localhost:5273/docs`** in your browser to view the API reference.
168
+
169
+ The server also exposes a few helpful informational routes:
170
+
171
+ - `GET /presets` — Returns a JSON array of all built-in named presets.
172
+ - `GET /template` — Returns a JSON object of all available settings keys and their defaults.
173
+ - `GET /health` — Returns server health status and engine version.
174
+
175
+ ## Automation
176
+
177
+ Imagerry CLI is designed to work well in automated environments.
178
+
179
+ For example, you can provide your license through an environment variable:
180
+
181
+ ```bash
182
+ export IMAGERRY_LICENSE_KEY="YOUR_KEY"
183
+
184
+ imagerry \
185
+ -i input.png \
186
+ -o output.png \
187
+ --preset=gradient
188
+ ```
189
+
190
+ When using a CI provider, store `IMAGERRY_LICENSE_KEY` as a secret rather than committing the license key to your repository.
191
+
192
+ > [!WARNING]
193
+ > Never commit your Imagerry license key to Git or include it directly in a public workflow configuration.
194
+
195
+ ## Troubleshooting
196
+
197
+ ### License issues
198
+
199
+ If your license cannot be verified, double-check that your key is valid and it belongs to Imagerry. If you lost your key or need help, please contact us at **support@imagerry.com**.
200
+
201
+ ## Privacy
202
+
203
+ Your source images stay on your machine or your own hosted server.
204
+
205
+ Imagerry CLI processes and renders all images locally. Images do not need to be uploaded to Imagerry or any external image-processing server.
206
+
207
+ The CLI only communicates with the licensing service when verifying your Imagerry Pro license.
208
+
209
+ ## Links
210
+
211
+ * [Imagerry](https://imagerry.com)
212
+ * [Legal & Terms](https://imagerry.com/legal)
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ import os from 'node:os';
3
+ import fs from 'node:fs';
4
+ import path from 'node:path';
5
+ import { spawnSync } from 'node:child_process';
6
+ import { createRequire } from 'node:module';
7
+
8
+ const platform = os.platform();
9
+ const arch = os.arch();
10
+
11
+ const packageName = `@imagerry/cli-${platform}-${arch}`;
12
+
13
+ try {
14
+ const require = createRequire(import.meta.url);
15
+
16
+ // Resolve the platform-specific package
17
+ const pkgPath = require.resolve(`${packageName}/package.json`);
18
+ const pkgDir = path.dirname(pkgPath);
19
+
20
+ // if (platform === 'android') {
21
+ // const entryPath = path.join(pkgDir, 'index.cjs');
22
+ // if (!fs.existsSync(entryPath)) {
23
+ // throw new Error(`Android JS entry not found at ${entryPath}`);
24
+ // }
25
+ // const { status, signal, error } = spawnSync('node', [entryPath, ...process.argv.slice(2)], {
26
+ // stdio: 'inherit',
27
+ // });
28
+ //
29
+ // if (error) throw error;
30
+ // if (signal) process.exit(1);
31
+ // process.exit(status ?? 0);
32
+ // }
33
+
34
+ const binName = platform === 'win32' ? 'imagerry.exe' : 'imagerry';
35
+ const binPath = path.join(pkgDir, binName);
36
+
37
+ if (!fs.existsSync(binPath)) {
38
+ throw new Error(`Native binary not found at ${binPath}`);
39
+ }
40
+
41
+ // Execute the binary and pass through all arguments
42
+ const { status, signal, error } = spawnSync(binPath, process.argv.slice(2), {
43
+ stdio: 'inherit',
44
+ windowsHide: true,
45
+ });
46
+
47
+ if (error) {
48
+ throw error;
49
+ }
50
+
51
+ if (signal) {
52
+ process.exit(1);
53
+ }
54
+
55
+ process.exit(status ?? 0);
56
+
57
+ } catch (err) {
58
+ console.error(`\n[Imagerry CLI] Failed to start native binary.`);
59
+ console.error(`Could not find the native executable for your platform (${platform}-${arch}).`);
60
+ console.error(`Please ensure the optional dependency "${packageName}" is installed.\n`);
61
+ console.error(err.message);
62
+ process.exit(1);
63
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@imagerry/cli",
3
+ "version": "0.1.5-beta",
4
+ "description": "Command-line interface for the Imagerry engine",
5
+ "homepage": "https://github.com/aj-seven/imagerry",
6
+ "engines": {
7
+ "node": ">=18.0.0"
8
+ },
9
+ "main": "bin/imagerry.js",
10
+ "type": "module",
11
+ "files": [
12
+ "bin"
13
+ ],
14
+ "bin": {
15
+ "imagerry": "bin/imagerry.js"
16
+ },
17
+ "optionalDependencies": {
18
+ "@imagerry/cli-darwin-arm64": "0.1.5-beta",
19
+ "@imagerry/cli-darwin-x64": "0.1.5-beta",
20
+ "@imagerry/cli-linux-arm64": "0.1.5-beta",
21
+ "@imagerry/cli-linux-x64": "0.1.5-beta",
22
+ "@imagerry/cli-win32-arm64": "0.1.5-beta",
23
+ "@imagerry/cli-win32-x64": "0.1.5-beta"
24
+ },
25
+ "keywords": [
26
+ "image",
27
+ "cli",
28
+ "customizer",
29
+ "imagerry",
30
+ "image-processing",
31
+ "automation",
32
+ "canvas",
33
+ "watermark",
34
+ "generator"
35
+ ],
36
+ "author": "Imagerry <support@imagerry.com>",
37
+ "license": "SEE LICENSE IN LICENSE.md",
38
+ "imagerry": {
39
+ "minimumVersion": "0.1.0-beta"
40
+ }
41
+ }