@enslo/sd-metadata 2.2.0 → 3.0.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 +50 -0
- package/README.ja.md +55 -4
- package/README.md +57 -6
- package/dist/index.d.ts +222 -191
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +8 -8
- package/dist/index.js +4571 -3294
- package/dist/index.js.map +1 -1
- package/docs/types.ja.md +121 -42
- package/docs/types.md +121 -42
- package/package.json +8 -8
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,111 +230,150 @@ 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
|
+
* Vendor that signed an image's C2PA Content Credentials.
|
|
289
|
+
*
|
|
290
|
+
* Coarse by design: a C2PA manifest identifies the producing vendor but not the
|
|
291
|
+
* specific model (e.g. Imagen and Gemini "Nano Banana" both map to `google`).
|
|
292
|
+
*/
|
|
293
|
+
type C2paVendor = 'openai' | 'google' | 'unknown';
|
|
294
|
+
/**
|
|
295
|
+
* Content Credentials (C2PA) read from an image's signed manifest.
|
|
296
|
+
*
|
|
297
|
+
* Unlike {@link GenerationMetadata}, this carries no prompt/sampling/size data:
|
|
298
|
+
* commercial AI tools (ChatGPT, Gemini, ...) embed provenance, not generation
|
|
299
|
+
* parameters. The manifest is read as declared — the cryptographic signature is
|
|
300
|
+
* NOT verified, so presence is not proof of authenticity (the strings are
|
|
301
|
+
* forgeable). Likewise,
|
|
302
|
+
* absence is not proof of human origin: Content Credentials are routinely
|
|
303
|
+
* stripped by screenshots, re-encoding, and social-media re-uploads.
|
|
304
|
+
*/
|
|
305
|
+
interface C2paMetadata {
|
|
306
|
+
/**
|
|
307
|
+
* Coarse vendor attribution from the manifest's claim generator / signer.
|
|
308
|
+
* Declared, not cryptographically verified — never treat as proof of origin.
|
|
309
|
+
*/
|
|
310
|
+
vendor: C2paVendor;
|
|
311
|
+
/**
|
|
312
|
+
* `true` when the manifest declares a trained-algorithmic (AI-generated) IPTC
|
|
313
|
+
* DigitalSourceType. Camera/scan source types are not flagged. This is the
|
|
314
|
+
* image's *declared*, unverified status: a `false`/absent result is not proof
|
|
315
|
+
* of human origin, and a `true` result is forgeable.
|
|
316
|
+
*/
|
|
317
|
+
aiGenerated: boolean;
|
|
318
|
+
/** Raw IPTC DigitalSourceType URI, surfaced verbatim when present. */
|
|
319
|
+
digitalSourceType?: string;
|
|
320
|
+
/** C2PA `claim_generator_info.name`, when present. */
|
|
321
|
+
claimGenerator?: string;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Parse result with 5-status design
|
|
290
325
|
*
|
|
291
|
-
* - `success`:
|
|
326
|
+
* - `success`: Generation metadata parsed; metadata and raw data available
|
|
327
|
+
* - `c2pa`: C2PA Content Credentials found (AI provenance, no generation params)
|
|
292
328
|
* - `empty`: No metadata found in the file
|
|
293
329
|
* - `unrecognized`: Metadata exists but format is not recognized
|
|
294
330
|
* - `invalid`: File is corrupted or not a valid image
|
|
295
331
|
*/
|
|
296
332
|
type ParseResult = {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
333
|
+
status: 'success';
|
|
334
|
+
metadata: GenerationMetadata;
|
|
335
|
+
raw: RawMetadata;
|
|
336
|
+
} | {
|
|
337
|
+
status: 'c2pa';
|
|
338
|
+
c2pa: C2paMetadata;
|
|
300
339
|
} | {
|
|
301
|
-
|
|
340
|
+
status: 'empty';
|
|
302
341
|
} | {
|
|
303
|
-
|
|
304
|
-
|
|
342
|
+
status: 'unrecognized';
|
|
343
|
+
raw: RawMetadata;
|
|
305
344
|
} | {
|
|
306
|
-
|
|
307
|
-
|
|
345
|
+
status: 'invalid';
|
|
346
|
+
message?: string;
|
|
308
347
|
};
|
|
309
348
|
/**
|
|
310
349
|
* Options for the read function
|
|
311
350
|
*/
|
|
312
351
|
interface ReadOptions {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
352
|
+
/**
|
|
353
|
+
* When true, dimensions are taken strictly from metadata only.
|
|
354
|
+
* When false (default), missing dimensions are extracted from image headers.
|
|
355
|
+
* @default false
|
|
356
|
+
*/
|
|
357
|
+
strict?: boolean;
|
|
319
358
|
}
|
|
320
359
|
/**
|
|
321
360
|
* Warning types for write operations
|
|
322
361
|
*/
|
|
323
362
|
type WriteWarning = {
|
|
324
|
-
|
|
325
|
-
|
|
363
|
+
type: 'metadataDropped';
|
|
364
|
+
reason: 'unrecognizedCrossFormat';
|
|
326
365
|
};
|
|
327
366
|
/**
|
|
328
367
|
* Error types for write operations
|
|
329
368
|
*/
|
|
330
369
|
type WriteError = {
|
|
331
|
-
|
|
370
|
+
type: 'unsupportedFormat';
|
|
332
371
|
} | {
|
|
333
|
-
|
|
334
|
-
|
|
372
|
+
type: 'conversionFailed';
|
|
373
|
+
message: string;
|
|
335
374
|
} | {
|
|
336
|
-
|
|
337
|
-
|
|
375
|
+
type: 'writeFailed';
|
|
376
|
+
message: string;
|
|
338
377
|
};
|
|
339
378
|
/**
|
|
340
379
|
* Result of the write operation
|
|
@@ -342,22 +381,15 @@ type WriteError = {
|
|
|
342
381
|
* Success case may include a warning when metadata was intentionally dropped.
|
|
343
382
|
*/
|
|
344
383
|
type WriteResult = {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
384
|
+
ok: true;
|
|
385
|
+
value: Uint8Array;
|
|
386
|
+
warning?: WriteWarning;
|
|
348
387
|
} | {
|
|
349
|
-
|
|
350
|
-
|
|
388
|
+
ok: false;
|
|
389
|
+
error: WriteError;
|
|
351
390
|
};
|
|
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
|
-
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/api/embed.d.ts
|
|
361
393
|
/**
|
|
362
394
|
* Embed metadata into an image
|
|
363
395
|
*
|
|
@@ -402,14 +434,8 @@ type WriteResult = {
|
|
|
402
434
|
* ```
|
|
403
435
|
*/
|
|
404
436
|
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
|
-
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/api/read.d.ts
|
|
413
439
|
/**
|
|
414
440
|
* Read and parse metadata from an image
|
|
415
441
|
*
|
|
@@ -421,14 +447,8 @@ declare function embed(input: Uint8Array | ArrayBuffer, metadata: EmbedMetadata
|
|
|
421
447
|
* @returns Parse result containing metadata and raw data
|
|
422
448
|
*/
|
|
423
449
|
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
|
-
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/api/stringify.d.ts
|
|
432
452
|
/**
|
|
433
453
|
* Build A1111-format text from EmbedMetadata
|
|
434
454
|
*
|
|
@@ -488,14 +508,8 @@ declare function formatRaw(raw: RawMetadata): string;
|
|
|
488
508
|
* ```
|
|
489
509
|
*/
|
|
490
510
|
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
|
-
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/api/write.d.ts
|
|
499
513
|
/**
|
|
500
514
|
* Write metadata to an image
|
|
501
515
|
*
|
|
@@ -508,7 +522,8 @@ declare function stringify(input: ParseResult | EmbedMetadata | GenerationMetada
|
|
|
508
522
|
* @returns New image data with embedded metadata (or warning if metadata was dropped)
|
|
509
523
|
*/
|
|
510
524
|
declare function write(input: Uint8Array | ArrayBuffer, metadata: ParseResult): WriteResult;
|
|
511
|
-
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/constants.d.ts
|
|
512
527
|
/**
|
|
513
528
|
* Human-readable display labels for each generation software identifier.
|
|
514
529
|
*
|
|
@@ -524,5 +539,21 @@ declare function write(input: Uint8Array | ArrayBuffer, metadata: ParseResult):
|
|
|
524
539
|
* ```
|
|
525
540
|
*/
|
|
526
541
|
declare const softwareLabels: Readonly<Record<GenerationSoftware, string>>;
|
|
527
|
-
|
|
528
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Human-readable display labels for each C2PA Content Credentials vendor.
|
|
544
|
+
*
|
|
545
|
+
* @example
|
|
546
|
+
* ```typescript
|
|
547
|
+
* import { c2paVendorLabels } from '@enslo/sd-metadata';
|
|
548
|
+
*
|
|
549
|
+
* const result = read(imageData);
|
|
550
|
+
* if (result.status === 'c2pa') {
|
|
551
|
+
* console.log(c2paVendorLabels[result.c2pa.vendor]);
|
|
552
|
+
* // => "OpenAI (ChatGPT)", "Google (Gemini)", ...
|
|
553
|
+
* }
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
declare const c2paVendorLabels: Readonly<Record<C2paVendor, string>>;
|
|
557
|
+
//#endregion
|
|
558
|
+
export { type BaseMetadata, type C2paMetadata, type C2paVendor, 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, c2paVendorLabels, embed, embed as writeAsWebUI, buildEmbedText as formatAsWebUI, formatRaw, read, softwareLabels, stringify, write };
|
|
559
|
+
//# 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,IAAA;AAAA;;;;UAMe,SAAA;EACf,IAAA;EA0BsB;EAxBtB,OAAA;EA0BI;EAxBJ,eAAA;EAwBQ;EAtBR,iBAAA;EA2B8B;EAzB9B,WAAA;EA2B6B;EAzB7B,iBAAA;EAyBQ;EAvBR,IAAA;AAAA;AAyBI;AAMN;;;AANM,KAdM,qBAAA;EACN,IAAA;AAAA;EACA,IAAA;EAA8B,MAAA;AAAA;EAC9B,IAAA;EAAkB,MAAA;AAAA;EAClB,IAAA;AAAA;EACA,IAAA;AAAA;;;AAkByC;UAb9B,eAAA;EAsBa;EApB5B,MAAA,EAAQ,qBAAqB;EAoBD;EAlB5B,IAAA;AAAA;;;;KAMU,WAAA;EACN,MAAA;EAAe,MAAA,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