@enslo/sd-parsers-web 1.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.
Files changed (48) hide show
  1. package/LICENSE +22 -0
  2. package/LICENSE.txt +21 -0
  3. package/README.md +221 -0
  4. package/dist/data/generators.d.ts +12 -0
  5. package/dist/data/generators.d.ts.map +1 -0
  6. package/dist/data/index.d.ts +10 -0
  7. package/dist/data/index.d.ts.map +1 -0
  8. package/dist/data/model.d.ts +25 -0
  9. package/dist/data/model.d.ts.map +1 -0
  10. package/dist/data/prompt.d.ts +20 -0
  11. package/dist/data/prompt.d.ts.map +1 -0
  12. package/dist/data/promptInfo.d.ts +56 -0
  13. package/dist/data/promptInfo.d.ts.map +1 -0
  14. package/dist/data/sampler.d.ts +24 -0
  15. package/dist/data/sampler.d.ts.map +1 -0
  16. package/dist/exceptions.d.ts +13 -0
  17. package/dist/exceptions.d.ts.map +1 -0
  18. package/dist/extractors/eagerness.d.ts +9 -0
  19. package/dist/extractors/eagerness.d.ts.map +1 -0
  20. package/dist/extractors/extractors.d.ts +30 -0
  21. package/dist/extractors/extractors.d.ts.map +1 -0
  22. package/dist/extractors/index.d.ts +14 -0
  23. package/dist/extractors/index.d.ts.map +1 -0
  24. package/dist/imageUtils.d.ts +16 -0
  25. package/dist/imageUtils.d.ts.map +1 -0
  26. package/dist/index.d.ts +23 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/parserManager.d.ts +26 -0
  29. package/dist/parserManager.d.ts.map +1 -0
  30. package/dist/parsers/automatic1111.d.ts +10 -0
  31. package/dist/parsers/automatic1111.d.ts.map +1 -0
  32. package/dist/parsers/comfyui.d.ts +10 -0
  33. package/dist/parsers/comfyui.d.ts.map +1 -0
  34. package/dist/parsers/dummy.d.ts +10 -0
  35. package/dist/parsers/dummy.d.ts.map +1 -0
  36. package/dist/parsers/fooocus.d.ts +10 -0
  37. package/dist/parsers/fooocus.d.ts.map +1 -0
  38. package/dist/parsers/index.d.ts +17 -0
  39. package/dist/parsers/index.d.ts.map +1 -0
  40. package/dist/parsers/invokeai.d.ts +13 -0
  41. package/dist/parsers/invokeai.d.ts.map +1 -0
  42. package/dist/parsers/novelai.d.ts +10 -0
  43. package/dist/parsers/novelai.d.ts.map +1 -0
  44. package/dist/parsers/parser.d.ts +38 -0
  45. package/dist/parsers/parser.d.ts.map +1 -0
  46. package/dist/sd-parsers-web.es.js +751 -0
  47. package/dist/sd-parsers-web.umd.js +4 -0
  48. package/package.json +62 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Deepratna Awale (original sd-parsers)
4
+ Copyright (c) 2025 Ernest Croft (browser adaptation)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 d3x-at
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ # SD-Parsers-Web
2
+
3
+
4
+ Read structured metadata from images created with stable diffusion - **Browser Edition**.
5
+
6
+ A TypeScript package for extracting prompt information and generation parameters from AI-generated images in the browser. You need images that are already embedded with generation data to use this library, it does not "predict" anything.
7
+
8
+ Website & API: https://sd-parsers.vercel.app/
9
+
10
+ > **Note**: This is a browser-only fork of sd-parsers, designed specifically for use in web applications without Node.js dependencies.
11
+
12
+ ![Example Output](example_output.png)
13
+
14
+ ## Features
15
+
16
+ Prompts as well as some well-known generation parameters are provided as easily accessible properties.
17
+
18
+ Supports reading metadata from images generated with:
19
+ * Automatic1111's Stable Diffusion web UI ✅
20
+ * Fooocus ✅
21
+ * ComfyUI ✅
22
+ * InvokeAI ✅
23
+ * NovelAI ✅
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install sd-parsers-web
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ### Basic usage:
34
+
35
+ For a simple query, import `ParserManager` from `sd-parsers-web` and use its `parse()` method to parse an image.
36
+
37
+ #### Read prompt information from a File object with `parse()`:
38
+
39
+ ```typescript
40
+ import { ParserManager } from 'sd-parsers-web';
41
+
42
+ const parserManager = new ParserManager();
43
+
44
+ async function handleFileInput(file: File) {
45
+ const promptInfo = await parserManager.parse(file);
46
+
47
+ if (promptInfo) {
48
+ for (const prompt of promptInfo.prompts) {
49
+ console.log(`Prompt: ${prompt.value}`);
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ #### Read prompt information from an ArrayBuffer:
56
+
57
+ ```typescript
58
+ import { ParserManager } from 'sd-parsers-web';
59
+
60
+ const parserManager = new ParserManager();
61
+
62
+ async function handleDrop(event: DragEvent) {
63
+ const file = event.dataTransfer?.files[0];
64
+ if (file) {
65
+ const arrayBuffer = await file.arrayBuffer();
66
+ const promptInfo = await parserManager.parse(arrayBuffer);
67
+
68
+ if (promptInfo) {
69
+ console.log(promptInfo);
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ #### Parse a remote image:
76
+
77
+ ```typescript
78
+ import { ParserManager } from 'sd-parsers-web';
79
+
80
+ const parserManager = new ParserManager();
81
+
82
+ async function parseRemoteImage(url: string) {
83
+ const response = await fetch(url);
84
+ const arrayBuffer = await response.arrayBuffer();
85
+ const promptInfo = await parserManager.parse(arrayBuffer);
86
+
87
+ if (promptInfo) {
88
+ console.log(promptInfo);
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Parsing options:
94
+
95
+ #### Configure metadata extraction:
96
+
97
+ ```typescript
98
+ import { ParserManager, Eagerness } from 'sd-parsers-web';
99
+
100
+ const parserManager = new ParserManager({ eagerness: Eagerness.EAGER });
101
+ ```
102
+
103
+ `Eagerness` sets the metadata searching effort:
104
+
105
+ - **FAST**: cut some corners to save some time
106
+ - **DEFAULT**: try to ensure all metadata is read (default)
107
+ - **EAGER**: include additional methods to try and retrieve metadata (computationally expensive!)
108
+
109
+ > **Browser Version Note**: Due to browser environment constraints, FAST and EAGER modes have limited functionality. DEFAULT mode (the default setting) is recommended for best results in the browser version.
110
+
111
+ #### Only use specific parser modules:
112
+
113
+ ```typescript
114
+ import { ParserManager, AUTOMATIC1111Parser } from 'sd-parsers-web';
115
+
116
+ const parserManager = new ParserManager({
117
+ managedParsers: [AUTOMATIC1111Parser]
118
+ });
119
+ ```
120
+
121
+ #### Debug mode:
122
+
123
+ ```typescript
124
+ import { ParserManager } from 'sd-parsers-web';
125
+
126
+ const parserManager = new ParserManager({ debug: true });
127
+ ```
128
+
129
+ ### Output
130
+
131
+ The parser returns a `PromptInfo` object with the following structure:
132
+
133
+ ```typescript
134
+ interface PromptInfo {
135
+ generator: Generators;
136
+ samplers: Sampler[];
137
+ metadata: Record<string, any>;
138
+ rawParameters: Record<string, any>;
139
+ }
140
+ ```
141
+
142
+ Access parsed data using helper functions:
143
+
144
+ ```typescript
145
+ import { getFullPrompt, getFullNegativePrompt, getModels } from 'sd-parsers-web';
146
+
147
+ const prompt = getFullPrompt(promptInfo);
148
+ const negativePrompt = getFullNegativePrompt(promptInfo);
149
+ const models = getModels(promptInfo);
150
+ ```
151
+
152
+ ## API Reference
153
+
154
+ ### Classes
155
+
156
+ - `ParserManager`: Main class for parsing images
157
+ - `AUTOMATIC1111Parser`: Parser for AUTOMATIC1111 webui images ✅
158
+ - `FooocusParser`: Parser for Fooocus images ✅
159
+ - `ComfyUIParser`: Parser for ComfyUI images ✅
160
+ - `InvokeAIParser`: Parser for InvokeAI images ✅
161
+ - `NovelAIParser`: Parser for NovelAI images ✅
162
+
163
+ ### Types
164
+
165
+ - `PromptInfo`: Contains structured image generation parameters
166
+ - `Sampler`: Represents a sampler used during image generation
167
+ - `Model`: Represents a checkpoint model
168
+ - `Prompt`: Represents an image generation prompt
169
+
170
+ ### Enums
171
+
172
+ - `Generators`: Supported image generators
173
+ - `Eagerness`: Metadata extraction effort levels
174
+
175
+ ## Development
176
+
177
+ ### Building
178
+
179
+ ```bash
180
+ npm run build
181
+ ```
182
+
183
+ ### Testing
184
+
185
+ ```bash
186
+ npm test
187
+ ```
188
+
189
+ ### Watch mode
190
+
191
+ ```bash
192
+ npm run dev
193
+ ```
194
+
195
+ ## Differences from Original sd-parsers
196
+
197
+ This browser-only fork has the following differences:
198
+
199
+ 1. **Designed for Browsers**: Optimized for browser environments; Node.js compatibility not tested or supported
200
+ 2. **Input Types**: Accepts `Blob | ArrayBuffer | Uint8Array` instead of file paths
201
+ 3. **No CLI**: Command-line interface removed
202
+ 4. **Image Processing**: Uses browser APIs instead of Sharp
203
+ 5. **EXIF Parsing**: Uses exifr library for JPEG EXIF data
204
+ 6. **Limited Eagerness Modes**:
205
+ - FAST mode: PNG IHDR parsing not implemented (returns null)
206
+ - EAGER mode: Stenographic analysis not available in browsers
207
+ - DEFAULT mode: Fully functional (recommended)
208
+
209
+ ## Contributing
210
+
211
+ Contributions are welcome! This is a browser-focused fork of the original sd-parsers library. If you find issues or want to add support for additional image generators, please open an issue or pull request.
212
+
213
+ ## License
214
+
215
+ MIT License - same as the original version.
216
+
217
+ ## Credits
218
+
219
+ - Original library: [sd-parsers](https://github.com/d3x-at/sd-parsers) by d3x-at
220
+ - TypeScript port: [sd-parsers](https://github.com/deepratna-awale/sd-parsers) by Deepratna Awale
221
+ - Browser adaptation: Ernest Croft
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Enumeration of supported image generators
3
+ */
4
+ export declare enum Generators {
5
+ AUTOMATIC1111 = "AUTOMATIC1111",
6
+ COMFYUI = "ComfyUI",
7
+ FOOOCUS = "Fooocus",
8
+ INVOKEAI = "InvokeAI",
9
+ NOVELAI = "NovelAI",
10
+ UNKNOWN = "unknown"
11
+ }
12
+ //# sourceMappingURL=generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../src/data/generators.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU;IACpB,aAAa,kBAAkB;IAC/B,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB"}
@@ -0,0 +1,10 @@
1
+ export { Generators } from './generators';
2
+ export type { Model } from './model';
3
+ export { createModel, modelToString } from './model';
4
+ export type { Prompt } from './prompt';
5
+ export { createPrompt, promptToString } from './prompt';
6
+ export type { Sampler } from './sampler';
7
+ export { createSampler } from './sampler';
8
+ export type { PromptInfo } from './promptInfo';
9
+ export { createPromptInfo, getFullPrompt, getFullNegativePrompt, getPrompts, getNegativePrompts, getModels, promptInfoToDict, promptInfoToJSON } from './promptInfo';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,UAAU,EACV,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Represents a checkpoint model used during image generation
3
+ */
4
+ export interface Model {
5
+ /** Name of the checkpoint model (if found) */
6
+ name?: string;
7
+ /** Hash value of the checkpoint model (if found) */
8
+ hash?: string;
9
+ /** Model id */
10
+ modelId?: string;
11
+ /** Additional generator-specific information. Highly dependent on the respective image generator. */
12
+ metadata: Record<string, any>;
13
+ }
14
+ /**
15
+ * Creates a new Model instance
16
+ */
17
+ export declare function createModel(options: Partial<Model> & {
18
+ name?: string;
19
+ hash?: string;
20
+ }): Model;
21
+ /**
22
+ * Returns string representation of the model
23
+ */
24
+ export declare function modelToString(model: Model): string;
25
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/data/model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,qGAAqG;IACrG,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAa7F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAKlD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Represents an image generation prompt
3
+ */
4
+ export interface Prompt {
5
+ /** The value of the prompt */
6
+ value: string;
7
+ /** Prompt id */
8
+ promptId?: string;
9
+ /** Additional generator-specific information. Highly dependent on the respective image generator. */
10
+ metadata: Record<string, any>;
11
+ }
12
+ /**
13
+ * Creates a new Prompt instance
14
+ */
15
+ export declare function createPrompt(value: string, options?: Partial<Pick<Prompt, 'promptId' | 'metadata'>>): Prompt;
16
+ /**
17
+ * Returns string representation of the prompt
18
+ */
19
+ export declare function promptToString(prompt: Prompt): string;
20
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/data/prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IAEd,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,qGAAqG;IACrG,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,CAAM,GAAG,MAAM,CAQhH;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -0,0 +1,56 @@
1
+ import { Generators } from './generators';
2
+ import { Model } from './model';
3
+ import { Prompt } from './prompt';
4
+ import { Sampler } from './sampler';
5
+ /**
6
+ * Contains structured image generation parameters
7
+ */
8
+ export interface PromptInfo {
9
+ /** Image generator which might have produced the parsed image */
10
+ generator: Generators;
11
+ /** Samplers used in generating the parsed image */
12
+ samplers: Sampler[];
13
+ /** Additional parameters which are found in the image metadata. Highly dependent on the respective image generator. */
14
+ metadata: Record<string, any>;
15
+ /** Unprocessed parameters as found in the parsed image */
16
+ rawParameters: Record<string, any>;
17
+ }
18
+ /**
19
+ * Creates a new PromptInfo instance
20
+ */
21
+ export declare function createPromptInfo(generator: Generators, samplers: Sampler[], metadata?: Record<string, any>, rawParameters?: Record<string, any>): PromptInfo;
22
+ /**
23
+ * Gets the full prompt if present in the image metadata.
24
+ * Otherwise, returns a simple concatenation of all prompts found in the generation data.
25
+ *
26
+ * Reproducibility of the source image using this data is not guaranteed (=rather unlikely).
27
+ */
28
+ export declare function getFullPrompt(promptInfo: PromptInfo): string;
29
+ /**
30
+ * Gets the full negative prompt if present in the image metadata.
31
+ * Otherwise, returns a simple concatenation of all negative prompts found in the generation data.
32
+ *
33
+ * Reproducibility of the source image using this data is not guaranteed (=rather unlikely).
34
+ */
35
+ export declare function getFullNegativePrompt(promptInfo: PromptInfo): string;
36
+ /**
37
+ * Gets unique prompts used in generating the parsed image
38
+ */
39
+ export declare function getPrompts(promptInfo: PromptInfo): Prompt[];
40
+ /**
41
+ * Gets unique negative prompts used in generating the parsed image
42
+ */
43
+ export declare function getNegativePrompts(promptInfo: PromptInfo): Prompt[];
44
+ /**
45
+ * Gets unique models used in generating the parsed image
46
+ */
47
+ export declare function getModels(promptInfo: PromptInfo): Model[];
48
+ /**
49
+ * Converts PromptInfo to a dictionary representation
50
+ */
51
+ export declare function promptInfoToDict(promptInfo: PromptInfo): Record<string, any>;
52
+ /**
53
+ * Converts PromptInfo to JSON string
54
+ */
55
+ export declare function promptInfoToJSON(promptInfo: PromptInfo): string;
56
+ //# sourceMappingURL=promptInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promptInfo.d.ts","sourceRoot":"","sources":["../../src/data/promptInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,SAAS,EAAE,UAAU,CAAC;IAEtB,mDAAmD;IACnD,QAAQ,EAAE,OAAO,EAAE,CAAC;IAEpB,uHAAuH;IACvH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE9B,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,UAAU,EACrB,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAClC,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GACtC,UAAU,CAOZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAO5D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAOpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAe3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAenE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,KAAK,EAAE,CAezD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAS5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAE/D"}
@@ -0,0 +1,24 @@
1
+ import { Model } from './model';
2
+ import { Prompt } from './prompt';
3
+ /**
4
+ * Represents a sampler used during image generation
5
+ */
6
+ export interface Sampler {
7
+ /** The name of the sampler */
8
+ name: string;
9
+ /** Generation parameters, including cfg_scale, seed, steps and others */
10
+ parameters: Record<string, any>;
11
+ /** A unique id for this sampler (if present in the metadata) */
12
+ samplerId?: string;
13
+ /** The checkpoint model used */
14
+ model?: Model;
15
+ /** Positive prompts used by this sampler */
16
+ prompts: Prompt[];
17
+ /** Negative prompts used by this sampler */
18
+ negativePrompts: Prompt[];
19
+ }
20
+ /**
21
+ * Creates a new Sampler instance
22
+ */
23
+ export declare function createSampler(name: string, parameters?: Record<string, any>, options?: Partial<Pick<Sampler, 'samplerId' | 'model' | 'prompts' | 'negativePrompts'>>): Sampler;
24
+ //# sourceMappingURL=sampler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampler.d.ts","sourceRoot":"","sources":["../../src/data/sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhC,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gCAAgC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,4CAA4C;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,4CAA4C;IAC5C,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,iBAAiB,CAAC,CAAM,GAC1F,OAAO,CAWT"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Base error class for parser-related errors
3
+ */
4
+ export declare class ParserError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /**
8
+ * Error thrown when metadata did not match our expectations - can be safely ignored
9
+ */
10
+ export declare class MetadataError extends ParserError {
11
+ constructor(message: string);
12
+ }
13
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enumeration of metadata extraction eagerness levels
3
+ */
4
+ export declare enum Eagerness {
5
+ FAST = 1,
6
+ DEFAULT = 2,
7
+ EAGER = 3
8
+ }
9
+ //# sourceMappingURL=eagerness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eagerness.d.ts","sourceRoot":"","sources":["../../src/extractors/eagerness.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,SAAS;IACnB,IAAI,IAAI;IACR,OAAO,IAAI;IACX,KAAK,IAAI;CACV"}
@@ -0,0 +1,30 @@
1
+ import { Generators } from '../data';
2
+ /**
3
+ * Type definition for metadata extractor functions (browser-compatible)
4
+ */
5
+ export type ExtractorFunction = (buffer: Uint8Array, generator: Generators) => Promise<Record<string, any> | null>;
6
+ /**
7
+ * Extract metadata from PNG image info
8
+ *
9
+ * Browser version note: This function currently returns null as browser APIs
10
+ * do not provide DPI/density information like Sharp does in Node.js.
11
+ * Kept for API compatibility with original library and future implementation.
12
+ */
13
+ export declare function pngImageInfo(buffer: Uint8Array, _: Generators): Promise<Record<string, any> | null>;
14
+ /**
15
+ * Extract metadata from PNG text chunks
16
+ */
17
+ export declare function pngImageText(buffer: Uint8Array, _: Generators): Promise<Record<string, any> | null>;
18
+ /**
19
+ * Extract metadata from PNG stenographic alpha channel
20
+ *
21
+ * Browser version note: Stenographic analysis is not implemented in the browser version.
22
+ * This feature requires specialized image processing that is not available in browsers.
23
+ * Kept for API compatibility with original library.
24
+ */
25
+ export declare function pngStenographicAlpha(buffer: Uint8Array, _: Generators): Promise<Record<string, any> | null>;
26
+ /**
27
+ * Extract metadata from JPEG UserComment EXIF field
28
+ */
29
+ export declare function jpegUserComment(buffer: Uint8Array, generator: Generators): Promise<Record<string, any> | null>;
30
+ //# sourceMappingURL=extractors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractors.d.ts","sourceRoot":"","sources":["../../src/extractors/extractors.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,KAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAazG;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CA6DzG;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAQjH;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CA0DpH"}
@@ -0,0 +1,14 @@
1
+ import { Eagerness } from './eagerness';
2
+ import { ExtractorFunction } from './extractors';
3
+ /**
4
+ * Metadata extractors organized by image format and eagerness level
5
+ *
6
+ * Browser version notes:
7
+ * - FAST mode: Limited functionality (PNG IHDR parsing not implemented)
8
+ * - DEFAULT mode: Recommended - fully functional for SD metadata extraction
9
+ * - EAGER mode: Stenographic features not available in browser environment
10
+ */
11
+ export declare const METADATA_EXTRACTORS: Record<string, Record<Eagerness, ExtractorFunction[]>>;
12
+ export { Eagerness } from './eagerness';
13
+ export { ExtractorFunction } from './extractors';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAqE,MAAM,cAAc,CAAC;AAEpH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAgBtF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Browser-compatible image utilities to replace Sharp functionality
3
+ */
4
+ /**
5
+ * 画像フォーマットをマジックバイトから検出
6
+ */
7
+ export declare function detectImageFormat(buffer: Uint8Array): string | null;
8
+ /**
9
+ * 画像の基本メタデータを取得(ブラウザAPI使用)
10
+ */
11
+ export declare function getImageMetadata(buffer: Uint8Array): Promise<{
12
+ width?: number;
13
+ height?: number;
14
+ format?: string;
15
+ }>;
16
+ //# sourceMappingURL=imageUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageUtils.d.ts","sourceRoot":"","sources":["../src/imageUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAqBnE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAyBD"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A library to read metadata from images created with Stable Diffusion.
3
+ *
4
+ * Basic usage:
5
+ * ```typescript
6
+ * import { ParserManager } from 'sd-parsers';
7
+ *
8
+ * const parserManager = new ParserManager();
9
+ *
10
+ * async function main() {
11
+ * const promptInfo = await parserManager.parse('image.png');
12
+ * if (promptInfo) {
13
+ * console.log(promptInfo);
14
+ * }
15
+ * }
16
+ * ```
17
+ */
18
+ export { ParserManager } from './parserManager';
19
+ export { Eagerness } from './extractors';
20
+ export * from './data';
21
+ export * from './parsers';
22
+ export * from './exceptions';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { PromptInfo } from './data';
2
+ import { Eagerness } from './extractors';
3
+ import { Parser } from './parsers';
4
+ /**
5
+ * Input types that can be parsed (browser-compatible)
6
+ */
7
+ export type ParseInput = Blob | ArrayBuffer | Uint8Array;
8
+ /**
9
+ * Provides a simple way of testing multiple parser modules against a given image
10
+ */
11
+ export declare class ParserManager {
12
+ private eagerness;
13
+ private debug;
14
+ private managedParsers;
15
+ constructor(options?: {
16
+ debug?: boolean;
17
+ eagerness?: Eagerness;
18
+ managedParsers?: (new (normalizeParameters?: boolean, debug?: boolean) => Parser)[];
19
+ normalizeParameters?: boolean;
20
+ });
21
+ /**
22
+ * Try to extract image generation parameters from the given image.
23
+ */
24
+ parse(input: ParseInput, eagerness?: Eagerness): Promise<PromptInfo | null>;
25
+ }
26
+ //# sourceMappingURL=parserManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parserManager.d.ts","sourceRoot":"","sources":["../src/parserManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAuB,SAAS,EAAqB,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,MAAM,EAAmB,MAAM,WAAW,CAAC;AAGpD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,WAAW,GAAG,UAAU,CAAC;AAEzD;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,cAAc,CAAW;gBAErB,OAAO,GAAE;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,cAAc,CAAC,EAAE,CAAC,KAAK,mBAAmB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC,EAAE,CAAC;QACpF,mBAAmB,CAAC,EAAE,OAAO,CAAC;KAC1B;IAiBN;;OAEG;IACG,KAAK,CACT,KAAK,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAiF9B"}
@@ -0,0 +1,10 @@
1
+ import { Parser } from './parser';
2
+ import { Generators, PromptInfo } from '../data';
3
+ /**
4
+ * Parser for images generated by AUTOMATIC1111's stable-diffusion-webui or similar
5
+ */
6
+ export declare class AUTOMATIC1111Parser extends Parser {
7
+ readonly generator = Generators.AUTOMATIC1111;
8
+ parse(parameters: Record<string, any>): Promise<PromptInfo>;
9
+ }
10
+ //# sourceMappingURL=automatic1111.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automatic1111.d.ts","sourceRoot":"","sources":["../../src/parsers/automatic1111.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA6B,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,UAAU,EAA8D,UAAU,EAAE,MAAM,SAAS,CAAC;AAc7G;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,MAAM;IAC7C,SAAgB,SAAS,4BAA4B;IAE/C,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CA2DlE"}
@@ -0,0 +1,10 @@
1
+ import { Parser } from './parser';
2
+ import { Generators, PromptInfo } from '../data';
3
+ /**
4
+ * Parser for images generated by ComfyUI
5
+ */
6
+ export declare class ComfyUIParser extends Parser {
7
+ readonly generator = Generators.COMFYUI;
8
+ parse(parameters: Record<string, any>): Promise<PromptInfo>;
9
+ }
10
+ //# sourceMappingURL=comfyui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comfyui.d.ts","sourceRoot":"","sources":["../../src/parsers/comfyui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,UAAU,EAA8D,UAAU,EAAW,MAAM,SAAS,CAAC;AAatH;;GAEG;AACH,qBAAa,aAAc,SAAQ,MAAM;IACvC,SAAgB,SAAS,sBAAsB;IAEzC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CAsBlE"}
@@ -0,0 +1,10 @@
1
+ import { Parser } from './parser';
2
+ import { Generators, PromptInfo } from '../data';
3
+ /**
4
+ * Example stub for additional parsers
5
+ */
6
+ export declare class DummyParser extends Parser {
7
+ readonly generator = Generators.UNKNOWN;
8
+ parse(parameters: Record<string, any>): Promise<PromptInfo>;
9
+ }
10
+ //# sourceMappingURL=dummy.d.ts.map