imagewright 0.1.0__tar.gz
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.
- imagewright-0.1.0/LICENSE +93 -0
- imagewright-0.1.0/PKG-INFO +318 -0
- imagewright-0.1.0/README.md +273 -0
- imagewright-0.1.0/pyproject.toml +170 -0
- imagewright-0.1.0/src/imagewright/__init__.py +36 -0
- imagewright-0.1.0/src/imagewright/_serving.py +75 -0
- imagewright-0.1.0/src/imagewright/cli.py +136 -0
- imagewright-0.1.0/src/imagewright/client.py +387 -0
- imagewright-0.1.0/src/imagewright/config.py +94 -0
- imagewright-0.1.0/src/imagewright/discovery.py +139 -0
- imagewright-0.1.0/src/imagewright/flux_server.py +261 -0
- imagewright-0.1.0/src/imagewright/mcp_image.py +77 -0
- imagewright-0.1.0/src/imagewright/mcp_server.py +96 -0
- imagewright-0.1.0/src/imagewright/sdxl_server.py +339 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject
|
|
14
|
+
to the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set
|
|
20
|
+
of the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other
|
|
27
|
+
notices of the licensor in the software. Any use of the licensor's trademarks
|
|
28
|
+
is subject to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license
|
|
39
|
+
for the software granted under these terms ends immediately. If your company
|
|
40
|
+
makes such a claim, your patent license ends immediately for work on behalf
|
|
41
|
+
of your company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from
|
|
46
|
+
you also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license
|
|
61
|
+
no later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your
|
|
64
|
+
licenses to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is
|
|
76
|
+
the software the licensor makes available under these terms, including any
|
|
77
|
+
portion of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that organization.
|
|
84
|
+
**control** means ownership of substantially all the assets of an entity, or
|
|
85
|
+
the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: imagewright
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Image generation over one HTTP contract: a client, local FLUX and SDXL servers, and an MCP tool
|
|
5
|
+
License-Expression: Elastic-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: image-generation,flux,sdxl,mflux,diffusers,mcp
|
|
8
|
+
Author: Eric G. Suchanek, PhD
|
|
9
|
+
Author-email: suchanek@flux-frontiers.com
|
|
10
|
+
Requires-Python: >=3.12,<3.14
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Provides-Extra: flux
|
|
19
|
+
Provides-Extra: mcp
|
|
20
|
+
Provides-Extra: openai
|
|
21
|
+
Provides-Extra: sdxl
|
|
22
|
+
Provides-Extra: serve
|
|
23
|
+
Requires-Dist: accelerate (>=0.33.0) ; extra == "sdxl"
|
|
24
|
+
Requires-Dist: click (>=8.1.0,<9)
|
|
25
|
+
Requires-Dist: diffusers (>=0.30.0) ; extra == "sdxl"
|
|
26
|
+
Requires-Dist: fastapi (>=0.116.0) ; extra == "serve"
|
|
27
|
+
Requires-Dist: httpx (>=0.27.0)
|
|
28
|
+
Requires-Dist: huggingface_hub (>=0.24.0) ; extra == "sdxl"
|
|
29
|
+
Requires-Dist: mcp (>=1.23.0,<2) ; extra == "mcp"
|
|
30
|
+
Requires-Dist: mflux (>=0.24.0) ; extra == "flux"
|
|
31
|
+
Requires-Dist: openai (>=1.30.0) ; extra == "openai"
|
|
32
|
+
Requires-Dist: pillow (>=13.0.0)
|
|
33
|
+
Requires-Dist: pydantic (>=2.8.0) ; extra == "serve"
|
|
34
|
+
Requires-Dist: safetensors (>=0.4.0) ; extra == "sdxl"
|
|
35
|
+
Requires-Dist: torch (>=2.4.0) ; extra == "sdxl"
|
|
36
|
+
Requires-Dist: transformers (>=4.44.0) ; extra == "sdxl"
|
|
37
|
+
Requires-Dist: uvicorn (>=0.30.0) ; extra == "serve"
|
|
38
|
+
Project-URL: Changelog, https://github.com/Flux-Frontiers/imagewright/blob/main/CHANGELOG.md
|
|
39
|
+
Project-URL: Documentation, https://flux-frontiers.github.io/imagewright/
|
|
40
|
+
Project-URL: Homepage, https://github.com/Flux-Frontiers/imagewright
|
|
41
|
+
Project-URL: Issues, https://github.com/Flux-Frontiers/imagewright/issues
|
|
42
|
+
Project-URL: Repository, https://github.com/Flux-Frontiers/imagewright
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# imagewright
|
|
46
|
+
|
|
47
|
+
[](https://www.python.org/)
|
|
48
|
+
[](https://www.elastic.co/licensing/elastic-license)
|
|
49
|
+
[](https://pypi.org/project/imagewright/)
|
|
50
|
+
[](https://github.com/Flux-Frontiers/imagewright/releases)
|
|
51
|
+
[](https://github.com/Flux-Frontiers/imagewright/actions/workflows/ci.yml)
|
|
52
|
+
[](https://flux-frontiers.github.io/imagewright/)
|
|
53
|
+
|
|
54
|
+
**imagewright** -- image generation over one HTTP contract.
|
|
55
|
+
|
|
56
|
+
*Eric G. Suchanek, PhD -- Flux-Frontiers*
|
|
57
|
+
|
|
58
|
+
imagewright generates images from text prompts. One contract,
|
|
59
|
+
`POST /v1/images/generations`, sits between the code that asks for an image
|
|
60
|
+
and the model that renders it, so the same call works against a local server,
|
|
61
|
+
a server on another machine, or a model loaded in the calling process.
|
|
62
|
+
|
|
63
|
+
It holds the image code that grew inside
|
|
64
|
+
[gutenberg_kg](https://github.com/Flux-Frontiers/gutenberg_kg) and
|
|
65
|
+
[KG_utils](https://github.com/Flux-Frontiers/kg_utils). That code never
|
|
66
|
+
depended on a knowledge graph, and neither does this package.
|
|
67
|
+
|
|
68
|
+
**Documentation:** [flux-frontiers.github.io/imagewright](https://flux-frontiers.github.io/imagewright/)
|
|
69
|
+
covers installation, choosing a backend, the servers, the HTTP contract, the
|
|
70
|
+
MCP server, every command and the Python API.
|
|
71
|
+
|
|
72
|
+
## Status
|
|
73
|
+
|
|
74
|
+
Alpha (0.1.0). The client, the in-process and OpenAI backends, both image
|
|
75
|
+
servers and the MCP tool work.
|
|
76
|
+
|
|
77
|
+
| Piece | State | What it does |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| Client | Done | Sends a prompt to any server that answers the contract and returns a PIL image. Finds a local server on ports 8090 and 8091 when none is configured |
|
|
80
|
+
| In-process mode | Done | Renders with FLUX.2 Klein in the calling process, with no server running. Needs the `flux` extra |
|
|
81
|
+
| OpenAI backend | Done | Sends the prompt to `gpt-image-1`. Needs the `openai` extra |
|
|
82
|
+
| `imagewright generate` | Done | Writes one PNG from a prompt |
|
|
83
|
+
| FLUX server | Done | `imagewright serve`. Serves FLUX.2 Klein through mflux on Apple Silicon. Keeps the model loaded between requests and can unload it when idle |
|
|
84
|
+
| SDXL server | Done | `imagewright serve --backend sdxl`. Serves SDXL-Lightning through diffusers on CUDA, MPS or CPU |
|
|
85
|
+
| MCP tool | Done | `imagewright-mcp`. Returns a generated image to an MCP client, compressed under the client's size limit. Needs the `mcp` extra |
|
|
86
|
+
|
|
87
|
+
## Install
|
|
88
|
+
|
|
89
|
+
imagewright is on PyPI and needs Python 3.12 or 3.13. The core install
|
|
90
|
+
talks to an image server. Extras add the other backends and the servers.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install imagewright # client for a running image server
|
|
94
|
+
pip install "imagewright[flux]" # + FLUX.2 Klein in process (Apple Silicon)
|
|
95
|
+
pip install "imagewright[openai]" # + OpenAI gpt-image-1
|
|
96
|
+
pip install "imagewright[serve,flux]" # + the FLUX server
|
|
97
|
+
pip install "imagewright[serve,sdxl]" # + the SDXL-Lightning server
|
|
98
|
+
pip install "imagewright[mcp]" # + the imagewright-mcp server
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
| Extra | Installs | For |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| `flux` | mflux | FLUX.2 Klein in process, and the FLUX server |
|
|
104
|
+
| `openai` | openai | The OpenAI backend |
|
|
105
|
+
| `serve` | fastapi, uvicorn, pydantic | Either server |
|
|
106
|
+
| `sdxl` | torch, diffusers, transformers, accelerate, safetensors, huggingface_hub | The SDXL server |
|
|
107
|
+
| `mcp` | mcp | `imagewright-mcp` and `as_mcp_image()` |
|
|
108
|
+
|
|
109
|
+
A backend whose extra is missing raises `MissingExtraError`, whose message
|
|
110
|
+
names the `pip install` command that fixes it. `imagewright serve` without
|
|
111
|
+
its extras, or `imagewright-mcp` without `mcp`, exits with the same
|
|
112
|
+
message.
|
|
113
|
+
|
|
114
|
+
## Generate an image
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
imagewright generate "a lighthouse at dusk, oil painting"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The command writes `imagewright-YYYYMMDD-HHMMSS.png` in the current directory
|
|
121
|
+
and prints its path. Options:
|
|
122
|
+
|
|
123
|
+
| Option | Meaning |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `--size WxH` | Output size, for example `1536x1024`. Default: 3:2, 1536x1024 |
|
|
126
|
+
| `--seed N` | Random seed for a reproducible image |
|
|
127
|
+
| `--steps N` | Inference steps for the FLUX backends. Default: 4 |
|
|
128
|
+
| `--backend NAME` | `mflux-serve`, `mflux-local` or `openai` |
|
|
129
|
+
| `--endpoint URL` | Image server base URL. Implies `mflux-serve` |
|
|
130
|
+
| `-o PATH` | Where to write the PNG |
|
|
131
|
+
|
|
132
|
+
### How the backend is chosen
|
|
133
|
+
|
|
134
|
+
1. `--backend` and `--endpoint`. An endpoint with no backend means
|
|
135
|
+
`mflux-serve`, whatever `IMAGE_BACKEND` says.
|
|
136
|
+
2. `IMAGE_BACKEND` and `IMAGE_ENDPOINT` (or `GUTENKG_IMAGE_ENDPOINT`) from
|
|
137
|
+
the environment. A configured endpoint is used without probing it.
|
|
138
|
+
3. A server that answers on `http://localhost:8090` or
|
|
139
|
+
`http://localhost:8091`. A server answers if `/health` or `/v1/models`
|
|
140
|
+
returns 200.
|
|
141
|
+
4. FLUX.2 Klein in process, if the `flux` extra is installed. A warning says
|
|
142
|
+
that no server was found and the model is loading in process.
|
|
143
|
+
5. Otherwise the command fails with a list of the ways to fix it.
|
|
144
|
+
|
|
145
|
+
A model loads in process only at step 4, or when `mflux-local` is named.
|
|
146
|
+
|
|
147
|
+
### Environment variables
|
|
148
|
+
|
|
149
|
+
| Variable | Meaning |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `IMAGE_BACKEND` | `mflux-serve`, `mflux-local` or `openai` |
|
|
152
|
+
| `IMAGE_ENDPOINT` | Image server base URL. Fallback: `GUTENKG_IMAGE_ENDPOINT` |
|
|
153
|
+
| `IMAGE_MODEL` | Model id. Fallback: `GUTENKG_IMAGE_MODEL` |
|
|
154
|
+
| `IMAGE_API_KEY` | OpenAI key. Fallback: `OPENAI_API_KEY` |
|
|
155
|
+
| `IMAGE_STEPS` | Inference steps. Default: 4 |
|
|
156
|
+
|
|
157
|
+
## Run an image server
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
imagewright serve # FLUX.2 Klein on 127.0.0.1:8090
|
|
161
|
+
imagewright serve --backend sdxl # SDXL-Lightning on 127.0.0.1:8091
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Both servers answer the same contract, the one gutenberg_kg's image servers
|
|
165
|
+
answer, so gutenberg_kg's worker and apps can point at either one unchanged:
|
|
166
|
+
|
|
167
|
+
| Route | Answers |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `GET /health` | `status`, `backend` and `model`; the FLUX server adds `loaded` and `idle_unload_s`. Does no model work, so it answers during a render and before the weights load |
|
|
170
|
+
| `GET /v1/models` | The one model the server serves, in OpenAI list format |
|
|
171
|
+
| `POST /v1/images/generations` | `prompt` (required), `size` (`WIDTHxHEIGHT`), `seed`, `num_inference_steps`, `response_format`; the SDXL server also takes `negative_prompt`. Returns `{"created": ..., "data": [{"b64_json": ...}]}`, or `{"filepath": ...}` for `response_format=filepath` |
|
|
172
|
+
|
|
173
|
+
Each server renders one image at a time. A size that does not parse
|
|
174
|
+
gives 1536x1024 on FLUX and 1024x1024 on SDXL. The SDXL server runs the
|
|
175
|
+
step count its Lightning UNet was trained for, whatever the request asks.
|
|
176
|
+
|
|
177
|
+
| Option | Meaning |
|
|
178
|
+
|---|---|
|
|
179
|
+
| `--backend flux\|sdxl` | Which server. Default: `flux` |
|
|
180
|
+
| `--host HOST` | Address to bind. Default: `MFLUX_SERVER_HOST` (`SDXL_SERVER_HOST` for sdxl), else `127.0.0.1` |
|
|
181
|
+
| `--port PORT` | Port to bind. Default: `MFLUX_SERVER_PORT` (`SDXL_SERVER_PORT` for sdxl), else 8090 (8091 for sdxl) |
|
|
182
|
+
|
|
183
|
+
The servers have no authentication, so they bind `127.0.0.1` by default.
|
|
184
|
+
gutenberg_kg's servers bound `0.0.0.0`; pass `--host 0.0.0.0` to share a
|
|
185
|
+
server on a network you trust.
|
|
186
|
+
|
|
187
|
+
Run one FLUX server per machine. Each holds 12-15 GB with the model loaded,
|
|
188
|
+
and every FLUX server defaults to port 8090, including the one gutenberg_kg
|
|
189
|
+
runs. To run a second one for a test, give it another port, for example
|
|
190
|
+
`--port 8092`.
|
|
191
|
+
|
|
192
|
+
### Server environment variables
|
|
193
|
+
|
|
194
|
+
| Variable | Server | Meaning |
|
|
195
|
+
|---|---|---|
|
|
196
|
+
| `IMAGE_MODEL` | FLUX | HF repo for FLUX.2 Klein. Fallback: `GUTENKG_IMAGE_MODEL`. Default: `mlx-community/flux2-klein-4b-4bit` |
|
|
197
|
+
| `IMAGE_STEPS` | FLUX | Steps when a request does not set them. Default: 4 |
|
|
198
|
+
| `IMAGE_PRELOAD` | FLUX | `1`, `true` or `yes` loads the model before the server accepts requests. Default: load on the first request |
|
|
199
|
+
| `IMAGE_IDLE_UNLOAD_S` | FLUX | Unload the model after this many idle seconds, so a small Mac gets its memory back; the next request reloads it. Default: 0, never |
|
|
200
|
+
| `MFLUX_SERVER_HOST`, `MFLUX_SERVER_PORT` | FLUX | Bind address and port, when `--host` and `--port` are not given |
|
|
201
|
+
| `SDXL_MODEL` | SDXL | `sdxl_lightning_2`, `sdxl_lightning_4` (default) or `sdxl_lightning_8` |
|
|
202
|
+
| `SDXL_BASE` | SDXL | SDXL base repo. Default: `stabilityai/stable-diffusion-xl-base-1.0` |
|
|
203
|
+
| `SDXL_OFFLINE` | SDXL | `1` never contacts Hugging Face; the weights must be cached. Default: download them on first run (about 7 GB) |
|
|
204
|
+
| `MPS_DTYPE` | SDXL | `float16` (default, with the fp16-fix VAE) or `float32` |
|
|
205
|
+
| `SDXL_SERVER_HOST`, `SDXL_SERVER_PORT` | SDXL | Bind address and port, when `--host` and `--port` are not given |
|
|
206
|
+
| `IMAGE_OUTPUT_DIR` | Both | Where `response_format=filepath` images go. Default: `imagewright_images` in the system temp directory |
|
|
207
|
+
|
|
208
|
+
The SDXL server builds its pipeline before it opens its port.
|
|
209
|
+
|
|
210
|
+
## Use it from an MCP client
|
|
211
|
+
|
|
212
|
+
`imagewright-mcp` is an MCP server over stdio with one tool, `generate`:
|
|
213
|
+
|
|
214
|
+
| Argument | Meaning |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `prompt` | Description of the image. Required; at most 4000 characters |
|
|
217
|
+
| `size` | `WIDTHxHEIGHT`. Default: `1536x1024` |
|
|
218
|
+
| `seed` | Integer seed for a reproducible image. Default: random |
|
|
219
|
+
| `steps` | Inference steps, 1-50. Default: `IMAGE_STEPS`, else 4 |
|
|
220
|
+
|
|
221
|
+
The tool chooses its backend on its first call, in the same order as
|
|
222
|
+
`imagewright generate`, and keeps it for the life of the server, so an
|
|
223
|
+
in-process model loads once. It returns the image as PNG, or as JPEG when the
|
|
224
|
+
PNG is over 3.75 MB (5 MB once base64-encoded, the usual MCP client limit).
|
|
225
|
+
|
|
226
|
+
To add it to Claude Code, put this in the project's `.mcp.json`:
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"mcpServers": {
|
|
231
|
+
"imagewright": { "command": "imagewright-mcp" }
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Python API
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
from imagewright import ImageSynthesizer, resolve_image_config
|
|
240
|
+
|
|
241
|
+
synth = ImageSynthesizer(resolve_image_config()) # same order as the CLI
|
|
242
|
+
image = synth.generate("a lighthouse at dusk", aspect_ratio="3:2", seed=7)
|
|
243
|
+
image.save("lighthouse.png")
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
| Name | What it is |
|
|
247
|
+
|---|---|
|
|
248
|
+
| `ImageSynthesizer(config)` | `generate(prompt, *, aspect_ratio="3:2", seed=None, steps=None, model=None, size=None)` returns a PIL image; `generate_b64(...)` returns a base64 PNG. For `mflux-local`, `load_model()`, `model_loaded` and `unload_model()` load, report and release the in-process model |
|
|
249
|
+
| `ImageConfig`, `ImageBackend` | The backend and its settings |
|
|
250
|
+
| `image_config_from_env()` | An `ImageConfig` from the environment variables above |
|
|
251
|
+
| `resolve_image_config(backend=None, endpoint=None)` | Chooses the backend in the order above |
|
|
252
|
+
| `discover_image_endpoint(candidates=None)` | The first image server that answers, or `None`. By default it probes `IMAGE_ENDPOINT` and `GUTENKG_IMAGE_ENDPOINT` (when set) before the two localhost ports |
|
|
253
|
+
| `DEFAULT_IMAGE_ENDPOINTS` | `http://localhost:8090`, `http://localhost:8091` |
|
|
254
|
+
| `NoImageBackendError` | Raised when no backend is available; the message lists the fixes |
|
|
255
|
+
| `MissingExtraError` | Raised when a backend's extra is not installed; a subclass of `ImportError` |
|
|
256
|
+
| `compress_image(image, max_bytes=MCP_IMAGE_MAX_BYTES)` | Encodes a PIL image in at most `max_bytes`: PNG if it fits, else JPEG at quality 85, 70 and 50, else JPEG shrunk by a quarter per round until it fits. Returns `(data, "png" or "jpeg")`. Needs only Pillow |
|
|
257
|
+
| `as_mcp_image(image, max_bytes=MCP_IMAGE_MAX_BYTES)` | `compress_image`, wrapped as the `mcp.server.fastmcp.Image` a FastMCP tool returns. Needs the `mcp` extra |
|
|
258
|
+
| `MCP_IMAGE_MAX_BYTES` | 3,750,000 |
|
|
259
|
+
|
|
260
|
+
## Install for development
|
|
261
|
+
|
|
262
|
+
imagewright uses Poetry. Development tools are a Poetry group, not an extra.
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
git clone https://github.com/Flux-Frontiers/imagewright.git
|
|
266
|
+
cd imagewright
|
|
267
|
+
poetry install --with dev
|
|
268
|
+
.venv/bin/pre-commit install
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The tests need no extras: the dev group carries the server and MCP stacks
|
|
272
|
+
(fastapi, uvicorn, pydantic, mcp), and the tests fake the model stacks. Install the `flux`
|
|
273
|
+
or `sdxl` extra only to run a real model.
|
|
274
|
+
|
|
275
|
+
## Run the checks
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
.venv/bin/pytest --cov
|
|
279
|
+
.venv/bin/pre-commit run --all-files
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
To confirm the install, run the command line:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
.venv/bin/imagewright --version
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
[Elastic License 2.0](https://www.elastic.co/licensing/elastic-license) -- see
|
|
291
|
+
[LICENSE](https://github.com/Flux-Frontiers/imagewright/blob/main/LICENSE).
|
|
292
|
+
|
|
293
|
+
The models are downloaded at run time and carry their own licenses.
|
|
294
|
+
FLUX.2 Klein 4B is Apache-2.0 and SDXL is OpenRAIL++. FLUX.2 Klein 9B is
|
|
295
|
+
licensed for non-commercial use only.
|
|
296
|
+
|
|
297
|
+
## Citation
|
|
298
|
+
|
|
299
|
+
If you use imagewright in your research or project, please cite it:
|
|
300
|
+
|
|
301
|
+
> Suchanek, E. G. (2026). *imagewright: Image Generation Over One HTTP Contract* (Version 0.1.0) [Software]. Flux-Frontiers. https://github.com/Flux-Frontiers/imagewright
|
|
302
|
+
|
|
303
|
+
```bibtex
|
|
304
|
+
@software{suchanek_imagewright,
|
|
305
|
+
author = {Suchanek, Eric G.},
|
|
306
|
+
title = {{imagewright}: Image Generation Over One HTTP Contract},
|
|
307
|
+
version = {0.1.0},
|
|
308
|
+
year = {2026},
|
|
309
|
+
publisher = {Flux-Frontiers},
|
|
310
|
+
url = {https://github.com/Flux-Frontiers/imagewright},
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
A Zenodo DOI is added here and in [CITATION.cff](https://github.com/Flux-Frontiers/imagewright/blob/main/CITATION.cff)
|
|
315
|
+
after the first release is archived. See the
|
|
316
|
+
[changelog](https://github.com/Flux-Frontiers/imagewright/blob/main/CHANGELOG.md)
|
|
317
|
+
for release history.
|
|
318
|
+
|