mirror of
https://github.com/coalaura/ffwebp.git
synced 2025-09-08 05:49:54 +00:00
--sniff
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user