ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Allison.nussbaum on November 07, 2022, 02:16:45 PM

Title: Exiftool -tagsfromfiles copy metadata from one file to another
Post by: Allison.nussbaum on November 07, 2022, 02:16:45 PM
I'm trying to copy the metadata from one image to another using the exiftool in Python but am having some trouble.

I'm using GDAL to compress the file (works properly) and then exiftool to copy the data over using the following code:

cmd='gdal_translate -co quality=3 -of JP2OpenJPEG "G-LiHT (6)_rgbi.jp2" "G-LiHT (6)_rgbi_comp3.jp2"'
os.system(cmd)
cmd2='exiftool -tagsfromfile "G-LiHT (6)_rgbi.jp2" -overwrite_original -ext "G-LiHT (6)_rgbi_comp3.jp2" .'
os.system(cmd2)

Is there something I'm missing here? The output in terminal is:
    1 directories scanned
    0 image files read

Thanks in advance!
Title: Re: Exiftool -tagsfromfiles copy metadata from one file to another
Post by: StarGeek on November 07, 2022, 03:30:09 PM
You should try running the command in Terminal first to make sure the command does what you want.

I can't help with the python stuff but one error I see is that you have the -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) without actually listing an extension. This option requires a second parameter. The result is that you're passing an extension of "G-LiHT (6)_rgbi_comp3.jp2"

There is a Python wrapper for exiftool called PyExifTool (https://pypi.org/project/PyExifTool/).  You might look into that as I believe it uses the -stay_open option (https://exiftool.org/exiftool_pod.html#stay_open-FLAG) which can speed commands up and avoid Common Mistake #3 (https://exiftool.org/mistakes.html#M3).