Copying Exif MetaData : Workflow and Prompt

Ask for help and post your question on how to use XnView MP.

Moderators: XnTriq, helmut, xnview

HiProfile
Posts: 3
Joined: Tue Nov 26, 2024 9:32 am

Copying Exif MetaData : Workflow and Prompt

Post by HiProfile »

Is there a way to copy the metadata of Workflow and Prompt generated by comfy UI from one PNG to another edited PNG while keeping the metadata intact in the new final image? Image editors like PhotoShop Destroy or remove that data.
The information is listed in the extra section of the EXIF Metadata. I see command-line tools to use EXIF Tool.exe to copy over the information, but I haven't tried it yet, and it's also command-line execution. I want to be able to copy the information in XnView, which allows me to see all the information and the photos at the same time. It would be nice to copy stuff once it's complete on an edited final image from the source data.
Also can it be copied from a PNG into a JPG?
Any advice on how to achieve this would be greatly appreciated.

See the image below wit the metadata showing from one of the info Tabs in XnView
metadata.png
You do not have the required permissions to view the files attached to this post.
User avatar
michel038
XnThusiast
Posts: 1410
Joined: Tue Sep 27, 2016 8:18 am
Location: France

Re: Copying Exif MetaData : Workflow and Prompt

Post by michel038 »

1 For a few individual photos or a large number?

2
Is there a way to copy the metadata of Workflow and Prompt generated by comfy UI from one PNG to another edited PNG while keeping the metadata intact in the new final image
You mean "Is there a way to copy the metadata of Workflow and Prompt generated by comfy UI from one PNG to another edited PNG while keeping the other metadata newly added by photosop intact in the new final image" ?

I think about a workaround :
- Export exif prompt and workflow in a file.txt with exiftool
- Import these data with exiftool in the new photo
We could create two "open with" functions, calling exiftool to process selected photos, inside XnViewmp.
Select source photo > right click > my-exiftool-export
Select target photo > right click > my-exiftool-import
Last edited by michel038 on Tue Nov 26, 2024 10:24 am, edited 1 time in total.
HiProfile
Posts: 3
Joined: Tue Nov 26, 2024 9:32 am

Re: Copying Exif MetaData : Workflow and Prompt

Post by HiProfile »

1: For a few individual photos or a large number?
For an individual file for now. I would go file by file to make sure what is being copied is transferred to the new file.
2: You mean "Is there a way to copy the metadata of Workflow and Prompt generated by comfy UI from one PNG to another edited PNG while keeping the other metadata newly added by photosop intact in the new final image" ?
Yes so I would have any new metadata added by photoshop such as copyright etc... and prompt and workflow in the new resulting image.
Realisctically that's a PS issue of whats in the XMP Exif Data Window. I don't see any Comfy kind of info or a way to add extra info
however if I could write the categories of the Metadata and copy the info from XnView that would work
Thanks
User avatar
michel038
XnThusiast
Posts: 1410
Joined: Tue Sep 27, 2016 8:18 am
Location: France

Re: Copying Exif MetaData : Workflow and Prompt

Post by michel038 »

We could create two "open with" functions, calling exiftool to process selected photos, inside XnViewmp.
Select source photo > right click > my-exiftool-export
Select target photo > right click > my-exiftool-import
it requires a few tests and time for development ...
Can you provide a link where we could download a small source photo and a [target photo where exif info are missing]

I think this export - import can work on any file types for which exiftool can read or write exif metadata
HiProfile
Posts: 3
Joined: Tue Nov 26, 2024 9:32 am

Re: Copying Exif MetaData : Workflow and Prompt

Post by HiProfile »

here are the files
1: The source file with the Metadata in it
http://hiprofile.ca/gallery/art/ComfyUI ... ster-3.png
2:the resulting file that was edited in Photoshop
http://hiprofile.ca/gallery/art/ComfyUI ... r-3_PS.png
Insert or add metadata specifically - Workflow and Prompt info and settings into file 2
User avatar
michel038
XnThusiast
Posts: 1410
Joined: Tue Sep 27, 2016 8:18 am
Location: France

Re: Copying Exif MetaData : Workflow and Prompt

Post by michel038 »

On which OS ?
Windows, Linux, Mac OS ?
I only use Windows ...

Small problems :
- 1 To simply export a metadata csv file , exiftool uses standard Windows redirection (>) , but it doesn't work in XnViewMP "File > Open with", so we'll have to use a bat file for export . And your metadatas contain commas, dots, ... ; we must use semicolons as separators.

export.bat

Code: Select all

"C:\XnViewMP\AddOn\exiftool.exe" -csvDelim ";" -csv -G -m  "-workflow" "-prompt" %1 >"C:\Users\MM\Documents\test\file11.txt"
pause
(set your own paths there)
Then, add a new "Open with" entry, linked to this "export.bat" file, named My-Export ( viewtopic.php?p=183222#p183222 )


- 2 Exiftool cannot easily write "workflow" and "prompt" metadatas ; we must set a ExifTool config file in XnViewMP\AddOn folder
https://exiftool.org/forum/index.php?topic=16491.0
- Create a new text file named "ConfigPrompt"

Code: Select all

# ComfyUI.config
# Config file for the workflow and prompt tags added by ComfyUI
# save this into a file called ComfyUI.config in the same directory as exiftool. You can then
# use this command to copy the tags
#    exiftool -config ComfyUI.config -TagsFromFile Source.Png -workflow -prompt Target.png
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::PNG::TextualData' => {
        # Example 12.  PNG:NewPngTag1
        workflow => { %unreg }, # (written by ComfyUI)
        # Example 13.  PNG:NewPngTag2
        prompt => { %unreg }, # (written by ComfyUI)
    },
);
1;
- 3 Now we'll use another bat file, to import metadata to target file

import.bat

Code: Select all

"C:\XnViewMP\AddOn\exiftool.exe" -config "C:\XnViewMP\AddOn\ConfigPrompt" -v -csvDelim ";" -csv="C:\Users\MM\Documents\tt\file11.txt" %1
pause
and then, link this import.bat file to a new "Open with" entry, named My-Import

Usage
Select a source file, Right Click, Open with, My-Export
Open File11.txt and replace the source file name by the target file name
Select the target file, Right Click, Open with, My-Import

When I have some time, I'll try to see if we can simplify by using -TagsFromFile as indicated in the exiftool forum.
But these long explanations have helped us to understand and learn, especially for me. :mrgreen: :mrgreen:

We can also read in the exiftoot post that jpg files do not support png:prompt and png:workflow metadatas ...