1
0
mirror of https://github.com/coalaura/ffwebp.git synced 2025-09-08 05:49:54 +00:00
This commit is contained in:
Laura
2025-08-12 15:47:54 +02:00
parent 9e754ddad8
commit ebd42dc4fd
2 changed files with 18 additions and 11 deletions

View File

@@ -29,16 +29,18 @@ func (s *Sniffed) String() string {
return builder.String()
}
func Sniff(reader io.Reader, input string) (*Sniffed, io.Reader, error) {
ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(input), "."))
if ext != "" {
codec, _ := FindCodec(ext)
if codec != nil {
return &Sniffed{
Header: []byte("." + ext),
Confidence: 100,
Codec: codec,
}, reader, nil
func Sniff(reader io.Reader, input string, ignoreExtension bool) (*Sniffed, io.Reader, error) {
if !ignoreExtension {
ext := strings.ToLower(strings.TrimPrefix(filepath.Ext(input), "."))
if ext != "" {
codec, _ := FindCodec(ext)
if codec != nil {
return &Sniffed{
Header: []byte("." + ext),
Confidence: 100,
Codec: codec,
}, reader, nil
}
}
}