drewnoakes / metadata-extractor-dotnet

Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Other
915 stars 158 forks source link

PNG metadata ? #417

Closed seghier closed 4 months ago

seghier commented 4 months ago

Hello How can i get metadata from the directory?

IReadOnlyList<MetadataExtractor.Directory> ExtractPNGdata(string imageFile)
{
    var metadata =  MetadataExtractor.Formats.Png.PngMetadataReader.ReadMetadata(imageFile);
    return metadata;
}
PNG-IHDR Directory (7 tags)
PNG-tEXt Directory (1 tag)
PNG-tEXt Directory (1 tag)
File Directory (3 tags)

I use this png file:

ComfyUI_00084_

seghier commented 4 months ago

I get this data, how can i convert it to json?

image

[PNG-tEXt] Textual Data - prompt: {"1": {"inputs": {"ckpt_name": "sd_xl_turbo_1.0_fp16.safetensors", "vae_name": "Baked VAE", "clip_skip": -1, "lora_name": "None", "lora_model_strength": 1.0, "lora_clip_strength": 1.0, "positive": ["11", 0], "negative": ["12", 0], "token_normalization": "none", "weight_interpretation": "comfy", "empty_latent_width": ["21", 0], "empty_latent_height": ["21", 1], "batch_size": 1}, "class_type": "Efficient Loader"}, "11": {"inputs": {"prompt": "The cinematic photo of the contemporary living room is\ndesigned by gold and luxury style, the floor is\nconcerned with red marble stone tile, cinematic,\nlighting, highly detailed, winter, golden hour"}, "class_type": "CR Prompt Text"}, "12": {"inputs": {"prompt": "bad art, text, watermark, blurry"}, "class_type": "CR Prompt Text"}, "13": {"inputs": {"control_net_name": "diffusion_pytorch_model.fp16.safetensors", "model": ["1", 0]}, "class_type": "DiffControlNetLoader"}, "15": {"inputs": {"strength": 0.7000000000000001, "start_percent": 0.0, "end_percent": 0.65, "positive": ["1", 1], "negative": ["1", 2], "control_net": ["13", 0], "image": ["16", 0]}, "class_type": "ControlNetApplyAdvanced"}, "16": {"inputs": {"image": "interior.jpg", "upload": "image"}, "class_type": "LoadImage", "is_changed": ["d4aa73f01388763c0bc02406237334e78a0327903fcbcce24fed789d10c9f357"]}, "17": {"inputs": {"seed": 0, "steps": 20, "cfg": 7.0, "sampler_name": "ddim", "scheduler": "ddim_uniform", "denoise": 1.0, "preview_method": "auto", "vae_decode": "true", "model": ["1", 0], "positive": ["15", 0], "negative": ["15", 1], "latent_image": ["1", 3], "optional_vae": ["1", 4]}, "class_type": "KSampler (Efficient)"}, "18": {"inputs": {"samples": ["17", 3], "vae": ["17", 4]}, "class_type": "VAEDecode"}, "19": {"inputs": {"filename_prefix": "ComfyUI", "images": ["18", 0]}, "class_type": "SaveImage"}, "20": {"inputs": {"images": ["17", 5]}, "class_type": "PreviewImage"}, "21": {"inputs": {"image": ["16", 0]}, "class_type": "Get image size"}}

drewnoakes commented 4 months ago

Looks like the value is already json. Pass the string to System.Text.Json APIs to parse it. Hunt around online for docs explaining this if needed.