replace an image with a new one with metas and filename

Started by sinus, September 27, 2023, 08:37:17 AM

Previous topic - Next topic

sinus

IMatch is so powerful and I'm blacking out right now.  ::)

I have an image in IMatch, filled with some metadata fields like description, title etc.
The file name is also perfect.

Now I find a better image, for example on a mobile.
I don't want to do anything else but swap the new photo with the old one.
That is, all metadata fields from the old picture and also the filename should be transferred to the new picture.

So that in the end I have the same text in the metadata fields in the new image and the same file name.
The old image can then be deleted.

Of course, I can do this "manually", but if there are, for example, 300 images, this is not so elegant.

Does anyone have an idea how to do this as easily and quickly as possible? I think, there must be a better solution than doing this "by hand", but I do not see a solution. 
Best wishes from Switzerland! :-)
Markus

thrinn

I don't see an easy solution that would work in all situations. It depends not only on your settings regarding relations and propagation, but also on the file type:

Case 1: A standalone JPG
Metadata is embedded in the JPG file itself. If you replace the JPG, you replace the metadata. Yes, IMatch will have a "copy" in its database, but a replaced JPG with the same name will be considered as "modified" and trigger a "Updating metadata". You would have to somehow "protect" what's in the database from being updated from the file metadata, and then trigger a writeback explicitly. Maybe you could play around with the many options that are available to control metadata import, but my gut feeling is that this will most likely interfere with your regular workflow.
I mention JPG just as an example. The same reasoning is valid for other file formats with embedded metadata.

Case 2: Replace a version of a master
This is the easiest situation - as long as the relevant metadata is maintained on the master und you have working propagation rules in place. Indeed, when I redevelop a JPG from a RAW file, I just overwrite the previous JPG. Metadata will then be filled by propagation from the master. But I think this is not what you want to achieve.

Case 3: Standalone file with XMP buddy
For file formats where the metadata is stored in a XMP buddy file, it might work to just replace the file. Most likely it will work best if the new file does not contain any metadata at all. Then, the XMP should still be the single point of truth. And because the XMP has the same name as the image file, everything should be consistent. Unfortunately, in real life, we all know that it is not uncommon to have (a part of) metadata also in the image file itself. So, you might run into the well-known "conflicting metadata" situation.

Thorsten
Win 10 / 64, IMatch 2018, IMA

sinus

Hi Thorsten
Thanks for your input!  :)

I am sorry, that I did not describe it better. 
Well, in my case the images are simply jpgs or pngs. 
Not relation, master, version and whatever, simply stand-alone-jpgs/pngs.

Hmm, to be honest, I thought, there is for sure an easy solution, but when I read your post, it seems to be not that easy. 
I will have to think about creating a version/master - situation, like your case 2.

Uh, I really thought, this is for sure easy, I only do not see it. :-[

I do now, like Mario wrote often: lay it aside and think about it.  ;D Maybe I will see a solution during sleeping in a dream.

Echt: vielen Dank für Deine Überlegungen. 






Best wishes from Switzerland! :-)
Markus

digedag

Quote from: sinus on September 27, 2023, 08:37:17 AMall metadata fields from the old picture [...] should be transferred
Hi, Markus,

maybe like this:
- Export metadata from OLD file using "Import & Export > Text Export" as *.csv
- Import metadata to NEW file using "Import & Export > Import CSV Files".

Except using "Renamer" I have no idea how to change the file name ... :(

Bernhard

Mario

There is no automatic way in IMatch do do such a thing.

Some tricky ExifTool command line magic should be able to copy metadata between groups of files (to copy from the old file to the new file). Check the documentation.

Or, try this:

1. Enable all metadata protection under Edit > Preferences > Metadata 2.
2. Copy the "better" file over the "less better" file.
3. After IMatch has ingested the file, make some tags in the MD panel as modified (click the pen).
4. Write back.

Use the Metadata Compare app to see if the current metadata has been written successfully to the replaced file.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Thanks, guys,

With your ideas I found now a way, quite convenient, to do this.

1) First, send the filename to a metadata-tag (with a Metadata-Template), if not already present
2) Copy all metadata 
3) Paste into the new file
4) Rename the file with the renamer with the choosen metadata-tag.

These 4 steps are quite quick done, really.  :)

I thought about the master-version from thrinn, but finally I did not try it.
The same with the idea from Bernhard, I tried it once, but for me it was a bit too complicated.

The idea from Mario would work, I think, but in the mean time I came on the solution above and it works really well. 

Thanks for your ideas!  :)




Best wishes from Switzerland! :-)
Markus

Darius1968

Can you perform your outlined procedure in bulk, across many files at once, or does it only work one-by-one? 

sinus

Darius,
My number one and four
1) First, send the filename to a metadata-tag (with a Metadata-Template), if not already present
4) Rename the file with the renamer with the choosen metadata-tag.
you can of course do for several files.

But two and three, I am afraid, works only one by one.

2) Copy all metadata
3) Paste into the new file

Maybe we could do this two steps also automatically, but I see at the moment no way. Maybe with the idea from Bernhard (Text-import-export), Automation or whatever, but I have no idea. Maybe it is simply not possible automatically, like Mario wrote.

If I think a bit further, the "idea" to replace an image with another one, but preserve all metadata including the filename, is a task, what I could use often.

Specially nowadays, where we use mobiles, become photos from friends, do several photos from the same thing and so on.
Then I do all the stuff with data, gps, filenaming and so on ... and discover a better image for this, but all other is the same.

In my case I added filenames and data to "placeholder-images". Then I looked for photos that matched the theme and wanted replace the placeholder with the real image.
 
In such cases it would be cool, if we could do this very easy automatically. 

But on the other hand, for me, it is not that important to add a feature request.  8) 



Best wishes from Switzerland! :-)
Markus

digedag

Quote from: Darius1968 on September 27, 2023, 05:08:43 PM[...[ procedure in bulk, across many files at once [...]
With CSV Export/Import this also works with a bunch of files at once.
Prerequisite: The imported file must have the same filename as the file you are exporting from.

Bernhard

janb83

I have the same need as you, replacing existing files with improved versions. This happens in a lot of scenarios, sometimes for hundreds of files at the same time:

- old private photo positive scan gets replaced by commercial scan
- photo positive scan gets replaced by photo negative scan
- WhatsApp distributed photo gets replaced by the original file
- distributed re-compressed version gets replaced by the original JPG

I was considering writing a feature request for this, but noticed two issues which are almost impossible to solve in an automated process:

- Face Annotations. While these COULD work if the dimensions of the picture did not change, they are still hard to get right and would require warnings and a complex workflow.
- Metadata that should actually be different between the old and new version. Yes, Subject Creation Date, descriptions, titles etc. one wants to copy from the old to the new. But other things like file creation and modification dates, camera/hardware and other technical data should NOT be copied to the new file from the old one.

The latter point is important for you too sinus, make sure you are not accidentally overwriting important technical metadata with wrong values.

So, right now, the only way to achieve the goal seems to be copy Metadata using this approach, which allows you to define which fields to copy, and then copying IMatch attributes as described here.

Maybe the situation could be improved by a dedicated "Copy data to replacement" functionality, which you could simply call after selecting replacement and original. It would need a way to configure the following:
- An existing metadata layout used as a definition for tags to copy
- The checkboxes from the paste attributes and data dialog
- Maybe: Additional metadata templates to run (similar to indexing)
- Whether or not to rename the "replacement" to the filename of the "original"
- Whether or not to move the (renamed) "replacement" to the location of the "original"

This would probably be a rather small feature request if there would be no need for configurations. Unfortunately, they are needed so I don't see Mario implementing this :(

janb83

Food for thought: Maybe most of this can be solved by an Automation Favorite instead :)

Mario


QuoteSo, right now, the only way to achieve the goal seems to be copy Metadata using this approach, which allows you to define which fields to copy, and then copying IMatch attributes as described here.
This post is old and outdated. Note that the Metadata Panel allows you to select the tags you want to copy, since IMatch 2023 back in June: Copying Metadata Between Files

Having complex criteria of which data to copy or keep between files requires a more complex workflow. No free lunch and all that.

Some users solve this by making the "replacement" files versions of the file they replace. Then use propagation to copy tags as needed, finally deleting the master and renaming the replacement file when desired.

The improved copy & paste abilities of the Metadata Panel in IMatch 2023 have solved many of these tricky problems. Especially when you stick to XMP (and maybe safe EXIF tags).

Copying EXIF metadata or maker notes between files is usually not a good idea.
Many EXIF fields depend on physical attributes of the original image, maker notes often have "pointers" to absolute byte addresses in the original file etc. If the application copying EXIF and maker note is not aware of that (or does not care), the maker notes in the target file will be often useless or maybe even cause applications which use these maker notes to crash.

ExifTool can do magic when it copies EXIF data and maker notes, but I generally advice against it.
A lot of the important EXIF data is mirrored in XMP anyway and that does not depend on the physical format or structure of the image.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook