photoprism/pkg/fs/ext.go
Michael Mayer 68ba289d6c CLI: Add "photoprism show config/formats" subcommands
Replaces "photoprism config", which could only display
current configuration values. Codecs and file formats
have been refactored along the way.

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2022-04-12 13:28:28 +02:00

27 lines
626 B
Go

package fs
import (
"strings"
)
const (
YamlExt = ".yml"
JpegExt = ".jpg"
AvcExt = ".avc"
FujiRawExt = ".raf"
CanonCr3Ext = ".cr3"
)
// NormalizeExt returns the file extension without dot and in lowercase.
func NormalizeExt(fileName string) string {
if dot := strings.LastIndex(fileName, "."); dot != -1 && len(fileName[dot+1:]) >= 1 {
return strings.ToLower(fileName[dot+1:])
}
return ""
}
// TrimExt removes unwanted characters from file extension strings, and makes it lowercase for comparison.
func TrimExt(ext string) string {
return strings.ToLower(strings.Trim(ext, " .,;:“”'`\""))
}