@enslo/sd-metadata 2.2.0 → 2.3.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/CHANGELOG.md +16 -0
- package/README.ja.md +3 -2
- package/README.md +3 -2
- package/dist/index.d.ts +165 -189
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +8 -8
- package/dist/index.js +4340 -3293
- package/dist/index.js.map +1 -1
- package/docs/types.ja.md +41 -41
- package/docs/types.md +41 -41
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.3.0] - 2026-05-30
|
|
9
|
+
|
|
10
|
+
### Improved
|
|
11
|
+
|
|
12
|
+
- **ComfyUI metadata parsing** (#219): Improved accuracy and coverage for
|
|
13
|
+
non-standard workflow topologies and custom nodes (`ShowText|pysssss`,
|
|
14
|
+
`PromptStashSaver`). Several edge cases that previously caused parse failures
|
|
15
|
+
or incorrect results — including workflows with `NaN`-containing JSON, node
|
|
16
|
+
references in model fields, and workflow-only PNG files — are now handled
|
|
17
|
+
correctly.
|
|
18
|
+
|
|
19
|
+
### Maintenance
|
|
20
|
+
|
|
21
|
+
- Add `index.d.ts.map` (declaration sourcemaps) to the published output (#216)
|
|
22
|
+
- Update development dependencies
|
|
23
|
+
|
|
8
24
|
## [2.2.0] - 2026-02-27
|
|
9
25
|
|
|
10
26
|
### Added
|
package/README.ja.md
CHANGED
|
@@ -148,7 +148,7 @@ fileInput.addEventListener('change', async (e) => {
|
|
|
148
148
|
// ==UserScript==
|
|
149
149
|
// @name My Script
|
|
150
150
|
// @namespace https://example.com
|
|
151
|
-
// @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@2.
|
|
151
|
+
// @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@2.3.0/dist/index.global.js
|
|
152
152
|
// ==/UserScript==
|
|
153
153
|
|
|
154
154
|
const response = await fetch(imageUrl);
|
|
@@ -365,7 +365,8 @@ if (text) {
|
|
|
365
365
|
**パラメータ:**
|
|
366
366
|
|
|
367
367
|
- `input` - 画像ファイルデータ(PNG、JPEG、またはWebP)
|
|
368
|
-
- `options` -
|
|
368
|
+
- `options` - オプションの読み込み設定
|
|
369
|
+
- `strict?: boolean`(デフォルト: `false`)— `true` の場合、寸法(`width` / `height`)はメタデータからのみ取得します。`false` の場合、メタデータに寸法がなければ画像ヘッダーから取得します。
|
|
369
370
|
|
|
370
371
|
**戻り値:**
|
|
371
372
|
|
package/README.md
CHANGED
|
@@ -148,7 +148,7 @@ For userscripts (Tampermonkey, Violentmonkey, etc.), load the IIFE build via `@r
|
|
|
148
148
|
// ==UserScript==
|
|
149
149
|
// @name My Script
|
|
150
150
|
// @namespace https://example.com
|
|
151
|
-
// @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@2.
|
|
151
|
+
// @require https://cdn.jsdelivr.net/npm/@enslo/sd-metadata@2.3.0/dist/index.global.js
|
|
152
152
|
// ==/UserScript==
|
|
153
153
|
|
|
154
154
|
const response = await fetch(imageUrl);
|
|
@@ -362,7 +362,8 @@ Reads and parses metadata from an image file.
|
|
|
362
362
|
**Parameters:**
|
|
363
363
|
|
|
364
364
|
- `input` - Image file data (PNG, JPEG, or WebP)
|
|
365
|
-
- `options` - Optional read options
|
|
365
|
+
- `options` - Optional read options
|
|
366
|
+
- `strict?: boolean` (default: `false`) — When `true`, dimensions (`width` / `height`) are taken strictly from metadata only. When `false`, missing dimensions are extracted from image headers.
|
|
366
367
|
|
|
367
368
|
**Returns:**
|
|
368
369
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* PNG text chunk (tEXt or iTXt)
|
|
3
4
|
*/
|
|
@@ -6,68 +7,68 @@ type PngTextChunk = TExtChunk | ITXtChunk;
|
|
|
6
7
|
* tEXt chunk (Latin-1 encoded text)
|
|
7
8
|
*/
|
|
8
9
|
interface TExtChunk {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
type: 'tEXt';
|
|
11
|
+
/** Chunk keyword (e.g., 'parameters', 'Comment') */
|
|
12
|
+
keyword: string;
|
|
13
|
+
/** Text content */
|
|
14
|
+
text: string;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* iTXt chunk (UTF-8 encoded international text)
|
|
17
18
|
*/
|
|
18
19
|
interface ITXtChunk {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
type: 'iTXt';
|
|
21
|
+
/** Chunk keyword */
|
|
22
|
+
keyword: string;
|
|
23
|
+
/** Compression flag (0=uncompressed, 1=compressed) */
|
|
24
|
+
compressionFlag: number;
|
|
25
|
+
/** Compression method (0=zlib/deflate) */
|
|
26
|
+
compressionMethod: number;
|
|
27
|
+
/** Language tag (BCP 47) */
|
|
28
|
+
languageTag: string;
|
|
29
|
+
/** Translated keyword */
|
|
30
|
+
translatedKeyword: string;
|
|
31
|
+
/** Text content */
|
|
32
|
+
text: string;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* Source location of a metadata segment.
|
|
35
36
|
* Used for round-tripping: reading and writing back to the correct location.
|
|
36
37
|
*/
|
|
37
38
|
type MetadataSegmentSource = {
|
|
38
|
-
|
|
39
|
+
type: 'exifUserComment';
|
|
39
40
|
} | {
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
type: 'exifImageDescription';
|
|
42
|
+
prefix?: string;
|
|
42
43
|
} | {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
type: 'exifMake';
|
|
45
|
+
prefix?: string;
|
|
45
46
|
} | {
|
|
46
|
-
|
|
47
|
+
type: 'jpegCom';
|
|
47
48
|
} | {
|
|
48
|
-
|
|
49
|
+
type: 'xmpPacket';
|
|
49
50
|
};
|
|
50
51
|
/**
|
|
51
52
|
* A single metadata segment with source tracking
|
|
52
53
|
*/
|
|
53
54
|
interface MetadataSegment {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
/** Source location of this segment */
|
|
56
|
+
source: MetadataSegmentSource;
|
|
57
|
+
/** Raw data string */
|
|
58
|
+
data: string;
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Raw metadata for write-back (preserves original format)
|
|
61
62
|
*/
|
|
62
63
|
type RawMetadata = {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
format: 'png';
|
|
65
|
+
chunks: PngTextChunk[];
|
|
65
66
|
} | {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
format: 'jpeg';
|
|
68
|
+
segments: MetadataSegment[];
|
|
68
69
|
} | {
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
format: 'webp';
|
|
71
|
+
segments: MetadataSegment[];
|
|
71
72
|
};
|
|
72
73
|
/**
|
|
73
74
|
* Known AI image generation software
|
|
@@ -77,46 +78,46 @@ type GenerationSoftware = 'novelai' | 'comfyui' | 'swarmui' | 'tensorart' | 'sta
|
|
|
77
78
|
* Base metadata fields shared by all tools
|
|
78
79
|
*/
|
|
79
80
|
interface BaseMetadata {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
/** Positive prompt */
|
|
82
|
+
prompt: string;
|
|
83
|
+
/** Negative prompt */
|
|
84
|
+
negativePrompt: string;
|
|
85
|
+
/** Model settings */
|
|
86
|
+
model?: ModelSettings;
|
|
87
|
+
/** Sampling settings */
|
|
88
|
+
sampling?: SamplingSettings;
|
|
89
|
+
/** Hires.fix settings (if applied) */
|
|
90
|
+
hires?: HiresSettings;
|
|
91
|
+
/** Upscale settings (if applied) */
|
|
92
|
+
upscale?: UpscaleSettings;
|
|
93
|
+
/** Image width */
|
|
94
|
+
width: number;
|
|
95
|
+
/** Image height */
|
|
96
|
+
height: number;
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
98
99
|
* NovelAI-specific metadata
|
|
99
100
|
*/
|
|
100
101
|
interface NovelAIMetadata extends BaseMetadata {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
software: 'novelai';
|
|
103
|
+
/** V4 character prompts (when using character placement) */
|
|
104
|
+
characterPrompts?: CharacterPrompt[];
|
|
105
|
+
/** Use character coordinates for placement */
|
|
106
|
+
useCoords?: boolean;
|
|
107
|
+
/** Use character order */
|
|
108
|
+
useOrder?: boolean;
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
111
|
* Character prompt with position (NovelAI V4)
|
|
111
112
|
*/
|
|
112
113
|
interface CharacterPrompt {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
/** Character-specific prompt */
|
|
115
|
+
prompt: string;
|
|
116
|
+
/** Character position (normalized 0-1) */
|
|
117
|
+
center?: {
|
|
118
|
+
x: number;
|
|
119
|
+
y: number;
|
|
120
|
+
};
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* ComfyUI-format metadata (ComfyUI, TensorArt, Stability Matrix)
|
|
@@ -138,17 +139,16 @@ type ComfyNodeInputValue = string | number | boolean | ComfyNodeReference | Comf
|
|
|
138
139
|
* ComfyUI node structure
|
|
139
140
|
*/
|
|
140
141
|
interface ComfyNode {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
is_changed?: string[] | null;
|
|
142
|
+
/** Node class type (e.g., "CheckpointLoaderSimple", "KSampler") */
|
|
143
|
+
class_type: string;
|
|
144
|
+
/** Node inputs */
|
|
145
|
+
inputs: Record<string, ComfyNodeInputValue>;
|
|
146
|
+
/** Node metadata (ComfyUI only) */
|
|
147
|
+
_meta?: {
|
|
148
|
+
/** Node title for display */title?: string;
|
|
149
|
+
};
|
|
150
|
+
/** Change detection hash (rare, for caching) */
|
|
151
|
+
is_changed?: string[] | null;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* ComfyUI node graph
|
|
@@ -162,14 +162,14 @@ type ComfyNodeGraph = Record<string, ComfyNode>;
|
|
|
162
162
|
* These tools always have nodes in all formats.
|
|
163
163
|
*/
|
|
164
164
|
interface BasicComfyUIMetadata extends BaseMetadata {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
software: 'comfyui' | 'tensorart' | 'stability-matrix';
|
|
166
|
+
/**
|
|
167
|
+
* ComfyUI node graph (required)
|
|
168
|
+
*
|
|
169
|
+
* Always present in all image formats (PNG, JPEG, WebP).
|
|
170
|
+
* Structure: Record<nodeId, ComfyNode> where ComfyNode contains inputs and class_type.
|
|
171
|
+
*/
|
|
172
|
+
nodes: ComfyNodeGraph;
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* SwarmUI-specific metadata
|
|
@@ -177,14 +177,14 @@ interface BasicComfyUIMetadata extends BaseMetadata {
|
|
|
177
177
|
* SwarmUI uses ComfyUI workflow format but nodes are only present in PNG.
|
|
178
178
|
*/
|
|
179
179
|
interface SwarmUIMetadata extends BaseMetadata {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
180
|
+
software: 'swarmui';
|
|
181
|
+
/**
|
|
182
|
+
* ComfyUI node graph (optional for SwarmUI)
|
|
183
|
+
*
|
|
184
|
+
* Only present in PNG format. JPEG/WebP contain SwarmUI parameters only.
|
|
185
|
+
* Structure: Record<nodeId, ComfyNode> where ComfyNode contains inputs and class_type.
|
|
186
|
+
*/
|
|
187
|
+
nodes?: ComfyNodeGraph;
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* ComfyUI-format metadata (union of BasicComfyUI and SwarmUI)
|
|
@@ -202,7 +202,7 @@ type ComfyUIMetadata = BasicComfyUIMetadata | SwarmUIMetadata;
|
|
|
202
202
|
* NovelAI's character prompts or ComfyUI's node graphs.
|
|
203
203
|
*/
|
|
204
204
|
interface StandardMetadata extends BaseMetadata {
|
|
205
|
-
|
|
205
|
+
software: 'sd-webui' | 'sd-next' | 'forge' | 'forge-classic' | 'forge-neo' | 'reforge' | 'easy-reforge' | 'invokeai' | 'civitai' | 'hf-space' | 'easydiffusion' | 'fooocus' | 'ruined-fooocus' | 'draw-things';
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
208
|
* Unified generation metadata (discriminated union)
|
|
@@ -230,60 +230,59 @@ type GenerationMetadata = NovelAIMetadata | ComfyUIMetadata | StandardMetadata;
|
|
|
230
230
|
* prompts and extras for the settings line.
|
|
231
231
|
*/
|
|
232
232
|
type EmbedMetadata = BaseMetadata & Pick<NovelAIMetadata, 'characterPrompts'> & {
|
|
233
|
-
|
|
234
|
-
extras?: Record<string, string | number>;
|
|
233
|
+
/** Additional key-value pairs for the settings line */extras?: Record<string, string | number>;
|
|
235
234
|
};
|
|
236
235
|
/**
|
|
237
236
|
* Model settings
|
|
238
237
|
*/
|
|
239
238
|
interface ModelSettings {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
/** Model name */
|
|
240
|
+
name?: string;
|
|
241
|
+
/** Model hash */
|
|
242
|
+
hash?: string;
|
|
243
|
+
/** VAE name */
|
|
244
|
+
vae?: string;
|
|
246
245
|
}
|
|
247
246
|
/**
|
|
248
247
|
* Sampling settings
|
|
249
248
|
*/
|
|
250
249
|
interface SamplingSettings {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
250
|
+
/** Sampler name */
|
|
251
|
+
sampler?: string;
|
|
252
|
+
/** Scheduler (sometimes included in sampler, sometimes separate) */
|
|
253
|
+
scheduler?: string;
|
|
254
|
+
/** Sampling steps */
|
|
255
|
+
steps?: number;
|
|
256
|
+
/** CFG scale */
|
|
257
|
+
cfg?: number;
|
|
258
|
+
/** Random seed */
|
|
259
|
+
seed?: number;
|
|
260
|
+
/** CLIP skip layers */
|
|
261
|
+
clipSkip?: number;
|
|
262
|
+
/** Denoising strength (ComfyUI only, typically 1.0 for txt2img) */
|
|
263
|
+
denoise?: number;
|
|
265
264
|
}
|
|
266
265
|
/**
|
|
267
266
|
* Hires.fix settings
|
|
268
267
|
*/
|
|
269
268
|
interface HiresSettings {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
269
|
+
/** Upscale factor */
|
|
270
|
+
scale?: number;
|
|
271
|
+
/** Upscaler name */
|
|
272
|
+
upscaler?: string;
|
|
273
|
+
/** Hires steps */
|
|
274
|
+
steps?: number;
|
|
275
|
+
/** Hires denoising strength */
|
|
276
|
+
denoise?: number;
|
|
278
277
|
}
|
|
279
278
|
/**
|
|
280
279
|
* Upscale settings (post-generation)
|
|
281
280
|
*/
|
|
282
281
|
interface UpscaleSettings {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
/** Upscaler name */
|
|
283
|
+
upscaler?: string;
|
|
284
|
+
/** Scale factor */
|
|
285
|
+
scale?: number;
|
|
287
286
|
}
|
|
288
287
|
/**
|
|
289
288
|
* Parse result with 4-status design
|
|
@@ -294,47 +293,47 @@ interface UpscaleSettings {
|
|
|
294
293
|
* - `invalid`: File is corrupted or not a valid image
|
|
295
294
|
*/
|
|
296
295
|
type ParseResult = {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
296
|
+
status: 'success';
|
|
297
|
+
metadata: GenerationMetadata;
|
|
298
|
+
raw: RawMetadata;
|
|
300
299
|
} | {
|
|
301
|
-
|
|
300
|
+
status: 'empty';
|
|
302
301
|
} | {
|
|
303
|
-
|
|
304
|
-
|
|
302
|
+
status: 'unrecognized';
|
|
303
|
+
raw: RawMetadata;
|
|
305
304
|
} | {
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
status: 'invalid';
|
|
306
|
+
message?: string;
|
|
308
307
|
};
|
|
309
308
|
/**
|
|
310
309
|
* Options for the read function
|
|
311
310
|
*/
|
|
312
311
|
interface ReadOptions {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
312
|
+
/**
|
|
313
|
+
* When true, dimensions are taken strictly from metadata only.
|
|
314
|
+
* When false (default), missing dimensions are extracted from image headers.
|
|
315
|
+
* @default false
|
|
316
|
+
*/
|
|
317
|
+
strict?: boolean;
|
|
319
318
|
}
|
|
320
319
|
/**
|
|
321
320
|
* Warning types for write operations
|
|
322
321
|
*/
|
|
323
322
|
type WriteWarning = {
|
|
324
|
-
|
|
325
|
-
|
|
323
|
+
type: 'metadataDropped';
|
|
324
|
+
reason: 'unrecognizedCrossFormat';
|
|
326
325
|
};
|
|
327
326
|
/**
|
|
328
327
|
* Error types for write operations
|
|
329
328
|
*/
|
|
330
329
|
type WriteError = {
|
|
331
|
-
|
|
330
|
+
type: 'unsupportedFormat';
|
|
332
331
|
} | {
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
type: 'conversionFailed';
|
|
333
|
+
message: string;
|
|
335
334
|
} | {
|
|
336
|
-
|
|
337
|
-
|
|
335
|
+
type: 'writeFailed';
|
|
336
|
+
message: string;
|
|
338
337
|
};
|
|
339
338
|
/**
|
|
340
339
|
* Result of the write operation
|
|
@@ -342,22 +341,15 @@ type WriteError = {
|
|
|
342
341
|
* Success case may include a warning when metadata was intentionally dropped.
|
|
343
342
|
*/
|
|
344
343
|
type WriteResult = {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
ok: true;
|
|
345
|
+
value: Uint8Array;
|
|
346
|
+
warning?: WriteWarning;
|
|
348
347
|
} | {
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
ok: false;
|
|
349
|
+
error: WriteError;
|
|
351
350
|
};
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* Embed API for sd-metadata
|
|
355
|
-
*
|
|
356
|
-
* Write user-created or parsed metadata in A1111 format to PNG, JPEG,
|
|
357
|
-
* or WebP images. Accepts both EmbedMetadata (custom metadata composed
|
|
358
|
-
* by the user) and GenerationMetadata (parsed output from AI tools).
|
|
359
|
-
*/
|
|
360
|
-
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/api/embed.d.ts
|
|
361
353
|
/**
|
|
362
354
|
* Embed metadata into an image
|
|
363
355
|
*
|
|
@@ -402,14 +394,8 @@ type WriteResult = {
|
|
|
402
394
|
* ```
|
|
403
395
|
*/
|
|
404
396
|
declare function embed(input: Uint8Array | ArrayBuffer, metadata: EmbedMetadata | GenerationMetadata): WriteResult;
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
* Read API for sd-metadata
|
|
408
|
-
*
|
|
409
|
-
* Handles reading and parsing metadata from images.
|
|
410
|
-
* Automatically detects image format and extracts embedded generation metadata.
|
|
411
|
-
*/
|
|
412
|
-
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/api/read.d.ts
|
|
413
399
|
/**
|
|
414
400
|
* Read and parse metadata from an image
|
|
415
401
|
*
|
|
@@ -421,14 +407,8 @@ declare function embed(input: Uint8Array | ArrayBuffer, metadata: EmbedMetadata
|
|
|
421
407
|
* @returns Parse result containing metadata and raw data
|
|
422
408
|
*/
|
|
423
409
|
declare function read(input: Uint8Array | ArrayBuffer, options?: ReadOptions): ParseResult;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
* Unified metadata stringification
|
|
427
|
-
*
|
|
428
|
-
* Builds A1111-format plain text from metadata and provides the stringify()
|
|
429
|
-
* public API for converting any metadata type to a human-readable string.
|
|
430
|
-
*/
|
|
431
|
-
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/api/stringify.d.ts
|
|
432
412
|
/**
|
|
433
413
|
* Build A1111-format text from EmbedMetadata
|
|
434
414
|
*
|
|
@@ -488,14 +468,8 @@ declare function formatRaw(raw: RawMetadata): string;
|
|
|
488
468
|
* ```
|
|
489
469
|
*/
|
|
490
470
|
declare function stringify(input: ParseResult | EmbedMetadata | GenerationMetadata): string;
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
* Write API for sd-metadata
|
|
494
|
-
*
|
|
495
|
-
* Handles writing metadata to images with automatic format conversion.
|
|
496
|
-
* Supports PNG, JPEG, and WebP formats.
|
|
497
|
-
*/
|
|
498
|
-
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/api/write.d.ts
|
|
499
473
|
/**
|
|
500
474
|
* Write metadata to an image
|
|
501
475
|
*
|
|
@@ -508,7 +482,8 @@ declare function stringify(input: ParseResult | EmbedMetadata | GenerationMetada
|
|
|
508
482
|
* @returns New image data with embedded metadata (or warning if metadata was dropped)
|
|
509
483
|
*/
|
|
510
484
|
declare function write(input: Uint8Array | ArrayBuffer, metadata: ParseResult): WriteResult;
|
|
511
|
-
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/constants.d.ts
|
|
512
487
|
/**
|
|
513
488
|
* Human-readable display labels for each generation software identifier.
|
|
514
489
|
*
|
|
@@ -524,5 +499,6 @@ declare function write(input: Uint8Array | ArrayBuffer, metadata: ParseResult):
|
|
|
524
499
|
* ```
|
|
525
500
|
*/
|
|
526
501
|
declare const softwareLabels: Readonly<Record<GenerationSoftware, string>>;
|
|
527
|
-
|
|
528
|
-
export { type BaseMetadata, type CharacterPrompt, type ComfyNode, type ComfyNodeGraph, type ComfyNodeInputValue, type ComfyNodeReference, type EmbedMetadata, type GenerationMetadata, type GenerationSoftware, type HiresSettings, type ITXtChunk, type MetadataSegment, type MetadataSegmentSource, type ModelSettings, type ParseResult, type PngTextChunk, type RawMetadata, type ReadOptions, type SamplingSettings, type TExtChunk, type UpscaleSettings, type WriteResult, type WriteWarning, embed, buildEmbedText as formatAsWebUI, formatRaw, read, softwareLabels, stringify, write
|
|
502
|
+
//#endregion
|
|
503
|
+
export { type BaseMetadata, type CharacterPrompt, type ComfyNode, type ComfyNodeGraph, type ComfyNodeInputValue, type ComfyNodeReference, type EmbedMetadata, type GenerationMetadata, type GenerationSoftware, type HiresSettings, type ITXtChunk, type MetadataSegment, type MetadataSegmentSource, type ModelSettings, type ParseResult, type PngTextChunk, type RawMetadata, type ReadOptions, type SamplingSettings, type TExtChunk, type UpscaleSettings, type WriteResult, type WriteWarning, embed, embed as writeAsWebUI, buildEmbedText as formatAsWebUI, formatRaw, read, softwareLabels, stringify, write };
|
|
504
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/api/embed.ts","../src/api/read.ts","../src/api/stringify.ts","../src/api/write.ts","../src/constants.ts"],"mappings":";;;;KAoBY,YAAA,GAAe,SAAA,GAAY,SAAS;;;;UAK/B,SAAA;EACf,IAAA;EAuBI;EArBJ,OAAA;EAgCU;EA9BV,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