This tool provides the capability to extract and parse metadata from images. It is inspired by the work of the civitai project and leverages some of their code for image metadata parses
- (1) Preprocessing, which extracts special attributes in a 'RegExp'
- (2) Extracting the primary attributes with 'split(': ') and split(', ')'
npm install --save stable-diffusion-image-metadata
{
"exifreader": "^4.13.0"
}
export { extract, parse, stringify } from 'stable-diffusion-image-metadata';
const image = 'https://image.png'; // or File | base64
const [parameters, isParameters] = await extract(image);
const metadata = parse(parameters);
const metadataStr = stringify(metadata);
[1.0.11] - 2023-09-09
- fixed parse: make preprocess config, there will already be more preprocessing configs in the future.
const preproccessConfigs = [
{ reg: /(ControlNet \d+): "([^"]+)"/g },
{ reg: /(Lora hashes): "([^"]+)"/g },
{ reg: /(Hashes): ({[^}]+})/g, key: 'hashes', value: preproccessFormatJSONValueFn },
//...There should be many configs that need to be preprocessed in the future
];
[1.0.10] - 2023-09-09
- remove 'buffer-big-endian.ts'
- fixed function 'extract' chinese problem