Add PNG and JPEG to WebP transcoding

WebP lossy mode offers up to 30% better compression than JPEG.
This commit is contained in:
Andrew Gaul
2017-01-14 19:26:45 -08:00
parent 7b3424fd18
commit 9518dc2f1a
4 changed files with 43 additions and 5 deletions

15
transcoder/util.go Normal file
View File

@ -0,0 +1,15 @@
package transcoder
import (
"net/http"
"strings"
)
func SupportsWebP(headers http.Header) bool {
for _, v := range strings.Split(headers.Get("Accept"), ",") {
if strings.SplitN(v, ";", 2)[0] == "image/webp" {
return true
}
}
return false
}