ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: jesperswi on October 19, 2023, 07:06:48 AM

Title: Mass import JSON-metadata to jpg's
Post by: jesperswi on October 19, 2023, 07:06:48 AM
I have a folder with many jpgs with corresponding metadata in json-format.
How can I add gpslongitude and gpslatitude from the json-files to every image? The TAGS in JSON are cameralongitudeDeg and cameralatitudeDeg.

The jpgs have are called xxxx.0.eo.jpg while the jsons are called xxxx.json. The "xxxx" is the samme for corresponding pairs.
Title: Re: Mass import JSON-metadata to jpg's
Post by: StarGeek on October 19, 2023, 11:23:43 AM
Quote from: jesperswi on October 19, 2023, 07:06:48 AMThe TAGS in JSON are cameralongitudeDeg and cameralatitudeDeg.

I'm assuming these are the names that exiftool outputs when you run it on the json file with the -s (-short) option (https://exiftool.org/exiftool_pod.html#s-NUM--short)?  If not, run exiftool on one to get the exact name that exiftool will be reading
exiftool -s file.json

QuoteThe jpgs have are called xxxx.0.eo.jpg while the jsons are called xxxx.json. The "xxxx" is the samme for corresponding pairs.

Try this command.  Make sure and test it out before running it in batch
exiftool -ext jpg -TagsFromFile %4f.json "-GPSPosition<$cameralatitudeDeg, $cameralongitudeDeg" /path/to/files/

The -ext (-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) is used to make sure exiftool doesn't waste time reading any file other than the jpgs.

The %4f.json means that exiftool will only take the first four characters of the jpg filename when looking for a matching json file.  See the -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for more details on the percent variables.
Title: Re: Mass import JSON-metadata to jpg's
Post by: jesperswi on October 20, 2023, 02:39:17 AM
Thank you, it worked!

Only had to change the %4f.json to include more characters.

Title: Re: Mass import JSON-metadata to jpg's
Post by: jesperswi on October 23, 2023, 05:29:28 AM
How can I add altitude as well? Tag from jpeg is "altitudem"
Title: Re: Mass import JSON-metadata to jpg's
Post by: StarGeek on October 23, 2023, 10:30:59 AM
Add
"-GPSAltitude*<altitudem"