allow passing -api parameters to exiftool by Blesmol · Pull Request #59 · barasher/go-exiftool (original) (raw)

You're bringing TestExtractAllBinaryMetadata as example. But isn't that a regression test, although initially you were mentioning non-regression tests? How do you differentiate here between both? In general I can add something like this. Need to see whether I can provide a binary testfile that is as small as possible.

The idea of this test is to check that the Api function is concretely working. The best way to test it is to try it with a concrete sample that returns something with the Api settings that exiftools does not return without it. It proves that it works at least in one use-case.

Here is a sample with an existing file in the repository :

barasher@linux:~/go/src/github.com/barasher/go-exiftool/testdata$ exiftool 20190404_131804.jpg | grep 'File Block Size'

barasher@linux:~/go/src/github.com/barasher/go-exiftool/testdata$ exiftool -api systemtags 20190404_131804.jpg | grep 'File Block Size'
File Block Size                 : 4096

I call it a non regression test because if anything changes with the exiftool's -api parameter (for instance, -api is renamed -api_parameter, this unit-test should not work anymore. In go-exiftool's point of view, if something that used to work does not work anymore, it is a regression. The test checks that there is not any regression concerning the parameter.

I think that we agree and that it is just a vocabulary issue :)


Which JSON serialization? Happy to test this as well, but wasn't aware that there is some JSON serialization anywhere.

go-exiftool uses internally exiftool's -j parameter that formats metadata in JSON:

barasher@linux:~/go/src/github.com/barasher/go-exiftool/testdata$ exiftool 20190404_131804.jpg
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72

barasher@linux:~/go/src/github.com/barasher/go-exiftool/testdata$ exiftool -j 20190404_131804.jpg
[{
  "Orientation": "Rotate 90 CW",
  "XResolution": 72,
  "YResolution": 72
}]

I feared that exiftools -api parameter could not be compatible with the -j parameter but it seems that it's ok:

barasher@linux:~/go/src/github.com/barasher/go-exiftool/testdata$ exiftool -j -api systemtags 20190404_131804.jpg 
[{
  "FileBlockSize": 4096
}]

So, this should be OK with go-exiftool