I'm trying to export the metadata data inside a JPG file into a TXT file for automatic comparison, but the exiftool exports the data as human readable format, when I need it to export it in the raw variable format I'm using this command right now:
exiftool -all -a -s -n 1.jpg > export.txt
however I get:
GPSAltitude : 363.672
GPSLatitude : 47.2267460833333
GPSLongitude : 8.67101438888889
When I need:
GPSAltitude=363.672
GPSLatitude=47.2267460833333
GPSLongitude=8.67101438888889
OR
Exif.GPSInfo.GPSAltitude=363.672
Exif.GPSInfo.GPSLatitude=47.2267460833333
Exif.GPSInfo.GPSLongitude=8.67101438888889
I cant believe I cant find this data anywhere and I'm sure I'm missing some command but I've read the documentation twice and spent an hour and a half googling everything , all I find is about sidecars, the closest I found was exporting as XMP XML sidecar and that would work but I would have to parse all the files to remove all the XML garbage and its a lot more work, there has to be a way to export the variables as raw variables to a text file, they need to be in this format so an automated script can parse them easily.
Any help would be appreciated.
I'm thinking exporting into a machine readable format other than text would probably work, but there's like 100s of them, anyone know what format would yield variable text data as expected?
To clear it up a bit.
using the XMP sidecar export gets me 1/2 way to what I'm looking for but the XML garbage breaks the whole thing, this is what gets exported:
<exif:GPSAltitude>45459/125</exif:GPSAltitude>
<exif:GPSLatitude>47,13.604765N</exif:GPSLatitude>
<exif:GPSLongitude>8,40.26086333E</exif:GPSLongitude>
Again thanks in advance for any assistance
Basically the idea is that what ever is exported, is exported in a format that is ready to be added to a command line on a script so it can be reused to add the info back in with exiftool, currently the exports all generate data that is not the same format as the format required to add it back into the image later, this is essentially the problem.
You can use the -p (-printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat) to display the data how you would like. You'd probably have to create a FMT file since you're looking for multi-line output. And you would have to list the tags you're interested in.
For all the data, you're going to have to do something else to reformat the output if you can't use any of the regular options such as Json, XML, or CSV. If you're on Linux/Mac, then you could use pipe the exiftool output into sed for reformating. On Windows, there are ports of sed available.
well I only want to display the data in the format that ExifTool already reads, just the variables it already reads in the format it uses for command line syntax, ill take a look at the format option
hmm i dont think the format option would work, as I do not know what variable values the image has, i would have to write a format file that encompasses all 300 possible combinations so the output would know what to do with them.... there has to be a simpler way
basically what we want to do is a batch file to "export" all variables in a jpg file onto a text file for storage/modification, so we can then use another batch file to "restore" those variables to the same image or another different image.
Kind of like a backup and restore function that uses plain text, but if the data export ExifTool extracts is not written in the same format it reads/uses to Inject it, it will not work.
Take a look at the -args (-argFormat) option (https://exiftool.org/exiftool_pod.html#args--argFormat).
But both the -j (-json) option (https://exiftool.org/exiftool_pod.html#j-JSONFILE--json) and the -csv option (https://exiftool.org/exiftool_pod.html#csv-CSVFILE) allow for exporting and re-importing data into files and are better options, IMO. See FAQ #12 (https://exiftool.org/faq.html#Q12) and FAQ #26 (https://exiftool.org/faq.html#Q26).
thanks for the reply, the both options are ok i guess, its not exactly what i needed but they are definitely workable options,
CSV exports them as a row instead of column which is breaks any scripts so that would be discarded, but the json one seems to do the job it exports like this:
"SourceFile": "a.jpg",
"ExifToolVersion": 12.38,
"FileName": "a.jpg",
"Directory": ".",
"FileSize": "10 MiB",
"FileModifyDate": "2022:06:24 00:09:26-05:00",
"FileAccessDate": "2022:06:28 23:54:38-05:00",
"FileCreateDate": "2022:06:28 23:48:39-05:00",
"FilePermissions": "-rw-rw-rw-",
"FileType": "JPEG",
"FileTypeExtension": "jpg",
"MIMEType": "image/jpeg",
"ExifByteOrder": "Little-endian (Intel, II)",
"ImageDescription": " ",
"Make": "SONY",
"Model": "ILCE-5100",
"Orientation": "Horizontal (normal)",
"XResolution": 350,
"YResolution": 350,
Which is acceptable, it retains the original variable names used to re-import the data into the images using exiftool without needing to make a translator, and though creative use of batch files I can replace the first " for a - , delete the last ", and change the ": " to = so it works out of the box, its great.
Thank you for the help StarGeek this solution is not perfect but it works!
Quote from: XionicFire on June 26, 2022, 05:49:33 PM
When I need:
GPSAltitude=363.672
GPSLatitude=47.2267460833333
GPSLongitude=8.67101438888889
Any help would be appreciated.
Is this close enough:
exiftool -a -G1 -s -n -X 1.jpg > export.txt
GPS:GPSLatitude='47.2267460833167'
GPS:GPSLongitude='8.67101438891944'
GPS:GPSAltitude='363.672'- Matti