diff --git a/README.md b/README.md index 6028f22..197f2c0 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ This package is based on the standard Go image package and works best along with ## Installation +Imaging requires Go version 1.2 or greater. + go get -u github.com/disintegration/imaging *[Git](http://git-scm.com/) and [Mercurial](http://mercurial.selenic.com/) are needed.* @@ -172,7 +174,7 @@ dstImage = imaging.Invert(srcImage) #### Open, Save, New, Clone Imaging package provides useful shortcuts for image loading, saving, creation and copying. -Open and Save functions support JPEG, PNG, TIFF and BMP images. +Open and Save functions support JPEG, PNG, TIFF, BMP and GIF images. External libraries can be used to load other image formats. ```go diff --git a/helpers.go b/helpers.go index ba1cf78..efb2d4e 100644 --- a/helpers.go +++ b/helpers.go @@ -4,7 +4,7 @@ import ( "fmt" "image" "image/color" - _ "image/gif" + "image/gif" "image/jpeg" "image/png" "math" @@ -34,11 +34,11 @@ func Open(filename string) (img image.Image, err error) { } // Save saves the image to file with the specified filename. -// The format is determined from the filename extension: "jpg" (or "jpeg"), "png", "tif" (or "tiff") and "bmp" are supported. +// The format is determined from the filename extension: "jpg" (or "jpeg"), "png", "tif" (or "tiff"), "bmp" and "gif" are supported. func Save(img image.Image, filename string) (err error) { format := strings.ToLower(filepath.Ext(filename)) okay := false - for _, ext := range []string{".jpg", ".jpeg", ".png", ".tif", ".tiff", ".bmp"} { + for _, ext := range []string{".jpg", ".jpeg", ".png", ".tif", ".tiff", ".bmp", ".gif"} { if format == ext { okay = true break @@ -78,6 +78,8 @@ func Save(img image.Image, filename string) (err error) { err = tiff.Encode(file, img, &tiff.Options{Compression: tiff.Deflate, Predictor: true}) case ".bmp": err = bmp.Encode(file, img) + case ".gif": + err = gif.Encode(file, img, nil) } return }