Suppose I have a jpg image file 1.jpg.
I make a copy of it named 1copy.jpg.
(now i have 2 copies of the same image)
Then several changes are made independently to EXIF attributes of the two images so now both have different values, and possibly different EXIF directory structure.
Now, my goal is to copy all the EXIF metadata of 1.jpg to 1copy.jpg so that afterwards the two files are identical (ignoring modification dates). How can this be done in Java, without copying the file again and without rewriting all the sections of 1copy.jpg?
Invoking ExifTool for example won't do the trick as it will rewrite the whole file.
Some Java libraries I looked at, copy the content of metadata attributes but the overall EXIF directory structure of the files may be different and the files would end up containing the same metadata attributes and values, but will not be equivalent byte-for-byte.
So the way I was thinking of doing this is to open file 1.jpg in binary mode, find the EXIF section (starts with FF1E) in both files. Copy byte for byte the whole EXIF section (and only that section) from the source to the destination file - i.e. replace the EXIF section in place, without rewriting any other section of the file.
If this approach is fine, is there any library that allows doing that?
Second question: I also want to do that to mp4 files. Can the same strategy be used?
Third question: just curious... When you make a change to an EXIF property in windows Explorer (e.g. Title) does Windows rewrite the whole file or does it just update the entry in the EXIF directory section of the file?