add webp support (decode only)

if any transformation is requested, webp images will be encoded and
served as jpeg or png, defaulting to jpeg if no format is specified.

Fixes #88
This commit is contained in:
Will Norris 2017-06-01 08:10:34 -07:00
parent b9cc9df4b6
commit 328044540e
3 changed files with 14 additions and 3 deletions

View file

@ -23,6 +23,7 @@ import (
"image/png"
"github.com/disintegration/imaging"
_ "golang.org/x/image/webp" // register webp format
"willnorris.com/go/gifresize"
)
@ -62,7 +63,7 @@ func Transform(img []byte, opt Options) ([]byte, error) {
if err != nil {
return nil, err
}
case "jpeg":
case "jpeg", "webp": // default to encoding webp as jpeg
quality := opt.Quality
if quality == 0 {
quality = defaultQuality