Copy information from an XMP tag to an EXif tag

Started by praetor, January 28, 2023, 03:35:34 PM

Previous topic - Next topic

praetor

How can information from an XMP tag be written into an EXif tag?
I use XnView to manage my images. If you assign a star (rating) for an image, this information is saved in the XMP tag "Rating". However, other programs do not evaluate XMP. I would therefore like to copy the rating information into the "Rating" tag using ExitTool. I need the correct syntax for this please.

Thanks, Greetings
praetor

StarGeek

Is the XMP in a sidecar or embedded in the image?  Slightly different depending on the location.

First grab the xmp2exif.args file and save it into the same directory as exiftool.

If the XMP data is in the file, then you would run
exiftool -@ xmp2exif.args /path/to/files/

If the data is in sidecar files
exiftool --ext XMP -TagsFromFile %d%f.xmp -@ xmp2exif.args /path/to/files/

Example output:
C:\>exiftool -G1 -a -s -alldates y:\!temp\Test4.jpg y:\!temp\Test4.xmp
======== y:/!temp/Test4.jpg
[XMP-exif]      DateTimeOriginal                : 2023:01:28 12:44:14-08:00
======== y:/!temp/Test4.xmp
[XMP-xmp]       CreateDate                      : 2023:01:28 12:42:26-08:00
    2 image files read

C:\>exiftool -P -overwrite_original -@ xmp2exif.args y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -alldates y:\!temp\Test4.jpg y:\!temp\Test4.xmp
======== y:/!temp/Test4.jpg
[ExifIFD]       DateTimeOriginal                : 2023:01:28 12:44:14
[XMP-exif]      DateTimeOriginal                : 2023:01:28 12:44:14-08:00
======== y:/!temp/Test4.xmp
[XMP-xmp]       CreateDate                      : 2023:01:28 12:42:26-08:00
    2 image files read

C:\>exiftool -P -overwrite_original -TagsFromFile %d%f.xmp -@ xmp2exif.args y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -alldates y:\!temp\Test4.jpg y:\!temp\Test4.xmp
======== y:/!temp/Test4.jpg
[ExifIFD]       DateTimeOriginal                : 2023:01:28 12:44:14
[XMP-exif]      DateTimeOriginal                : 2023:01:28 12:44:14-08:00
[ExifIFD]       CreateDate                      : 2023:01:28 12:42:26
======== y:/!temp/Test4.xmp
[XMP-xmp]       CreateDate                      : 2023:01:28 12:42:26-08:00
    2 image files read
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

praetor

Thank you for your prompt reply!
The XMP data is embedded in the file.
Unfortunately I wasn't successful with the hints.
Calling exiftool -@ xmp2exif.args test.JPG leads to:
Warning: [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto - test.JPG
Warning: No writable tags set from test.JPG
     0 image files updated
     1 image files unchanged
The real problem may be the warning "No writable tags set". I'm attaching an example image here.
Incidentally, I'm not interested in copying all the XMP data to EXIF, just the "Rating" or "PercentRating" tag.

StarGeek

Sorry, I should have double checked to make sure that the xmp2exif.args copied Rating.  The EXIF:Rating tag is marked as "Avoid", so it will have to be explicitly copied.

exiftool "-EXIF:Rating<XMP:Rating" "-EXIF:RatingPercent<XMP:RatingPercent" /path/to/files/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

praetor