I'm having limited success dumping EXIF from a single image file to a JSON text file with output file path specified. I want to use absolute paths for everything.
Here's my command line:
"D:\tools\exiftool.exe" -n -json -w! "%0fE:\TestSubFolder\out_json.tmp" "E:\test_images\image.jpg"
This works or partially works depending on where or how it's called. Ultimately I need to call this from within another application. This is what I observe:
1) Command pasted to command line console:
Works! Outputs json file to E:\TestSubFolder\out_json.tmp
2) From test.cmd
Fails with error
Error creating image.jpgtest.cmdfE:\TestSubFolder\out_json.tmp
It is possible to get output from the .cmd method, however control over the output filename/path is problematic. It seems to mangle the .cmd file path and source image file name as part of the format, which should cancel out due to %0f as answered here: "How to change the output file name with -w" (https://exiftool.org/forum/index.php?topic=12013.0)
3) From C++ CreateProcessW()
Writes file E:\TestSubFolder\out_json.tmp
but content is not json!
I have double checked the command line arg[0] is the module file name or path, in fact it won't work without that. The command line and parameters otherwise appear correct. Other operations such as modifying EXIF and overwriting an image file have worked with this method.
Any idea what's going on here?
All % characters must be doubled in a cmd file.
- Phil
Quote from: Phil Harvey on March 29, 2023, 08:03:33 AMAll % characters must be doubled in a cmd file.
Thanks Phil! .cmd now works with the double percents.
Any idea about the lack of honoring -json from CreateProcess?
I'm still scratching my head about that one. The command appears to otherwise work and if I copy and paste from the string to command prompt, it runs correctly.
If I remove -json from normal test, I see text output like:
ExifTool Version Number : 12.58
File Name : test_exif2.jpg
Directory : .
File Size : 161713
Zone Identifier : Exists
File Modification Date/Time : 2023:01:04 09:45:02+10:00
File Access Date/Time : 2023:03:30 09:08:24+10:00
File Creation Date/Time : 2023:01:04 09:45:02+10:00
File Permissions : 100666
File Type : JPEG
File Type Extension : JPG
MIME Type : image/jpeg
Exif Byte Order : II
Image Description :
Make : NIKON
Camera Model Name : COOLPIX P6000
Orientation : 1
X Resolution : 300
But from CreateProcess, (with -json) the output looks like:
ExifToolVersion = 12.58
FileName = test_exif2.jpg
Directory = E:/test_dump
FileSize = 161713
ZoneIdentifier = Exists
FileModifyDate = 1672789502.03097
FileAccessDate = 1680053141.57221
FileCreateDate = 1672789502.01899
FilePermissions = 33206
FileType = JPEG
FileTypeExtension = JPG
MIMEType = image/jpeg
JPEG APP1 (11256 bytes):
ExifByteOrder = II
+ [IFD0 directory with 12 entries]
| 0) ImageDescription =
| - Tag 0x010e (32 bytes, string[32])
| 1) Make = NIKON
| - Tag 0x010f (6 bytes, string[6])
| 2) Model = COOLPIX P6000
| - Tag 0x0110 (14 bytes, string[14])
| 3) Orientation = 1
| - Tag 0x0112 (2 bytes, int16u[1])
| 4) XResolution = 300 (300/1)
| - Tag 0x011a (8 bytes, rational64u[1])
Was hoping showing this output might help guess what could be going wrong.
It could be helpful to show your code to call CreateProccess, but the output you show is the verbose level 2 output, so somehow the -v2 option is getting into the command.
- Phil
Thank you so much! The -v2 was it.
I had #defined some debugging, to add -k and -v2.
-v2 when modifying an image displays extra info to the console window, but when outputting just the metadata to file, it seems the file captures that instead.
So after I 'fixed' the CreateProcess by ensuring arg[0] was module name, I broke it with the extra params for debugging, which were appended separately.
Your application has very many options, and mixing them can produce unexpected results. For example, I originally tried to write EXIF via -long -json format options, but it seems -long is only for reading.
Thank you for your assistance!