diff --git a/include/OpenColorIO/OpenColorTransforms.h b/include/OpenColorIO/OpenColorTransforms.h index 19bf1496a4..e37c59e4c2 100644 --- a/include/OpenColorIO/OpenColorTransforms.h +++ b/include/OpenColorIO/OpenColorTransforms.h @@ -1070,6 +1070,13 @@ class OCIOEXPORT FileTransform : public Transform static const char * GetFormatNameByIndex(int index); /// Get the LUT reader extension at index, return empty string if an invalid index is specified. static const char * GetFormatExtensionByIndex(int index); + /// Returns true if the extension corresponds to a format supported by FileTransform. + /// The argument is case-insensitive, and a leading dot, if present, is ignored. + /// Note that FileTransform will attempt all format readers on a given file until it is + /// successful, even files that contain an unsupported extension or no extension. + /// However, this function is useful for applications that want to know which files are likely + /// to be LUT files, based on their extension. + static bool IsFormatExtensionSupported(const char * extension); FileTransform & operator=(const FileTransform &) = delete; /// Do not use (needed only for pybind11). diff --git a/src/OpenColorIO/transforms/FileTransform.cpp b/src/OpenColorIO/transforms/FileTransform.cpp index 9aeae8df43..faf1d343e3 100755 --- a/src/OpenColorIO/transforms/FileTransform.cpp +++ b/src/OpenColorIO/transforms/FileTransform.cpp @@ -158,6 +158,11 @@ const char * FileTransform::GetFormatExtensionByIndex(int index) return FormatRegistry::GetInstance().getFormatExtensionByIndex(FORMAT_CAPABILITY_READ, index); } +bool FileTransform::IsFormatExtensionSupported(const char * extension) +{ + return FormatRegistry::GetInstance().isFormatExtensionSupported(extension); +} + std::ostream& operator<< (std::ostream& os, const FileTransform& t) { os << "