Tensor.Art
Create

Fix EXIF data from EMS-#####-EMS using ExifTool


Updated:

Introduction

You download your images from this website but the EXIF data for the model / lora looks like:

Model: EMS-342970-EMS, or <lora:EMS-45352-EMS:0.500000>.

The ExifTool utility can fix this. I am using linux but it should also work for mac/Windows if you follow https://exiftool.org/install.html

PreReq

- Download ExifTool from https://exiftool.org/ and extract the archive into your home drive.

- Make a new dot-file called .ExifTool_config in the same folder as exiftool.

- linux example: ~/Image-ExifTool-12.86/.ExifTool_config

- windows might need cmd like: echo.>.ExifTool_config

.ExifTool_config file

Edit the config file. Copy/paste the basic example.

- This is perl language, search and replace, and not optimized, but it works. Switch is probably more efficient.

- The \+ is an escape for the + in the model name.

- The /g at the end searches for all instances.

- 'Parameters' is the block it changes in the EXIF.

- Add all your desired entries and save the file.

You only need to make new entries like:

$val =~ s/EMS-151022-EMS/RealCartoon Realistic v11/g;


%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyParameters=> {
            Require => 'Parameters',
            ValueConv => q{
                # MODEL
                $val =~ s/EMS-151022-EMS/RealCartoon Realistic v11/g;
                $val =~ s/EMS-219023-EMS/ShampooMix_v4-fp16-no-ema/g;
                $val =~ s/EMS-230098-EMS/RealCartoon Realistic v12/g;
                $val =~ s/EMS-379840-EMS/Lazymix\+ - v4/g;

                # LoRa
                $val =~ s/EMS-72516-EMS/Realistic Fusion X - V1/g;
                $val =~ s/EMS-343944-EMS/A simple nun suit - v1/g;

                return $val;
                },
            },
        },
);
1; # end

Modify the EXIF

I use linux, extracted to a folder inside my home folder, and my files are in my Downloads folder, so the command I run is this, where "~/Downloads" has my raw files:

perl ~/Image-ExifTool-12.86/exiftool  "-Parameters<MyParameters" ~/Downloads

It will make new files and append "original" to the old, however you can add -overwrite_original to delete the old files once absolutely sure your config file works. This does not forgive. I am not responsible for lost EXIF.

Copy into folders based on Model

This will parse your EXIF for the Model: and grab until the first comma, copy the file into a subfolder of the destination named as the Model. Ideally you already modified the EXIF to fix the model name. In this example the files are in my home Downloads folder on linux.

- ~/Downloads/ is the source folder with the files

- /path/to/destination/ is the destination parent folder. You need to change this

- -r is recursive, if you choose, make it -r -o .

- The "-o ." is the copy argument. Remove for move, at your own risk.

- If you only run this without first doing the above section you'll get a bunch of EMS-###-EMS folders. The next section will combine everything together into one command.

perl ~/Image-ExifTool-12.86/exiftool -if '($Parameters=~/Model/i)' -o . '-Directory</path/to/destination/${Parameters;m/\bModel:\s+(\w+[^,]*)/;$_=$1;}' ~/Downloads/

Combine into one command

This combines the above into one command. This example does a move not a copy. I also renamed my exiftool folder.

- ~/Downloads There are two. Rename those to the folder with your EMS-###-EMS pictures

- /path/to/destination/ Where you want to move the files after renaming the EMS-###-EMS to Model name

perl ~/ExifTool/exiftool -if '($Parameters=~/Model/i)'  "-Parameters<MyParameters" ~/Downloads -overwrite_original -execute  '-Directory</path/to/destination/${Parameters;m/\bModel:\s+(\w+[^,]*)/;$_=$1;}' ~/Downloads

Notes

You can rename the Image-ExifTool-12.86 directory or have it wherever.

On Windows you might need to change the ' to " when referencing directories.

This runs perl code so maybe rename exiftool to something else for safety.

ExifTool created by Phil Harvey. Very impressive. Active community and forum at the creator's website.

It can do advanced operations and scripting. Above my pay grade.

Please understand this post isn't an offer for support. This took me all day to figure out. I don't know what I am doing.

0

Comments