ExifTool Forum

ExifTool => The Image::ExifTool API => Topic started by: Hayo Baan on August 29, 2016, 02:29:11 PM

Title: Determine if a NikonCapture block is present
Post by: Hayo Baan on August 29, 2016, 02:29:11 PM
Hi Phil,

What is the best way (via the API) to determine if a file contains a NikonCapture block? It is irrelevant which tags are present in the block, I just need to know if the NikonCapture block is present or not.
Title: Re: Determine if a NikonCapture block is present
Post by: Phil Harvey on August 29, 2016, 10:01:05 PM
I would say test the NikonCaptureData tag, but you will have to request this tag by name to be sure it is extracted.

- Phil
Title: Re: Determine if a NikonCapture block is present
Post by: Hayo Baan on August 30, 2016, 02:06:14 AM
Hi Phil, I haven't tested this with the API, but on the command line this doesn't work. Even if the block is available, testing with e.g. '-if $NikonCapture' didn't work. I had to use e.g, a tag inside the block for this to work (which I don't want to do as the tag might not be there all the time). '-if $NikonCapture:all', however, does  work too so I guess I am actually looking for the API version of this :)
Title: Re: Determine if a NikonCapture block is present
Post by: Phil Harvey on August 30, 2016, 07:15:55 AM
Hi Hayo.  Not "NikonCapture".  Try "NikonCaptureData" as I mentioned.

The API version of $NikonCapture:all would be tricky.

- Phil
Title: Re: Determine if a NikonCapture block is present
Post by: Hayo Baan on August 30, 2016, 10:41:43 AM
Quote from: Phil Harvey on August 30, 2016, 07:15:55 AM
Hi Hayo.  Not "NikonCapture".  Try "NikonCaptureData" as I mentioned.

Doh, should have read your reply better ::)
Looks like this will work as I intended, great!

Quote from: Phil Harvey on August 30, 2016, 07:15:55 AM
The API version of $NikonCapture:all would be tricky.
Nah, NikonCaptureData will do, I think. So for my full understanding, I guess NikonCaptureData is the tag inside the makernotes which you then further analyse and synthesise into separate NikonCapture tags?

Thanks,
Hayo
Title: Re: Determine if a NikonCapture block is present
Post by: Phil Harvey on August 30, 2016, 10:57:09 AM
Quote from: Hayo Baan on August 30, 2016, 10:41:43 AM
Nah, NikonCaptureData will do, I think. So for my full understanding, I guess NikonCaptureData is the tag inside the makernotes which you then further analyse and synthesise into separate NikonCapture tags?

Correct.  Directory-type tags like this that are accessible as blocks have a "Writable" type other than "-" in the Tag Name documentation (https://exiftool.org/TagNames/Nikon.html).

- Phil
Title: Re: Determine if a NikonCapture block is present
Post by: Hayo Baan on August 30, 2016, 01:18:29 PM
Excellent, just one further question. In my script I want to delete the block, but when I set the value to undef, I get the following error: "Sorry, MakerNotes:NikonCaptureData is unsafe for writing", what's the solution for this?
Title: Re: Determine if a NikonCapture block is present
Post by: Phil Harvey on August 30, 2016, 09:29:33 PM
If you're calling SetNewValue(), you must call it with Protected => 1 to be able to write unsafe tags.

- Phil
Title: Re: Determine if a NikonCapture block is present
Post by: Hayo Baan on August 31, 2016, 12:44:56 AM
Right, I knew I missed something... Probably read about this in the past, but forgot ::)