JoshOBrien / exiftoolr

ExifTool Functionality from R
https://joshobrien.github.io/exiftoolr/
23 stars 1 forks source link

Check for exiftool on new installation #6

Closed EOGrady21 closed 2 years ago

EOGrady21 commented 2 years ago

I'm looking to use this package to check some image metadata within a shiny app.

The trick is that I have to make sure the machine running the shiny app has exiftools.

Is there a way to check that exiftool is available before attempting to run exiftoolr functionality?

Thanks!

JoshOBrien commented 2 years ago

Would something like this do the trick? It will return TRUE if a functioning version of ExifTool (plus, if needed, Perl) is available, and otherwise FALSE.

is_exiftool_available <- function() {
    !is.null(tryCatch(exif_version(), error = function(e) NULL))
}
is_exiftool_available()

If you are not on Windows and using the Windows ExifTool executable, and want to first check whether Perl is available, you could possibly do something like this, which uses the unexported function exiftoolr:::configure_perl():

is_perl_available <- function() {
    !is.null(tryCatch(exiftoolr:::configure_perl(), error = function(e) NULL))
}
is_perl_available()
EOGrady21 commented 2 years ago

That will work perfectly! Thanks so much for your help! 🥇

JoshOBrien commented 2 years ago

@EOGrady21 Great. Glad to hear that!