Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (28 sloc) 0.654 kb
package mogrify
import (
"bytes"
"fmt"
"io"
)
// Gif image that can be transformed.
type Gif struct {
// Embed GdImage and all it's methods
GdImage
}
// DecodeGif decodes a GIF image from a reader.
func DecodeGif(reader io.Reader) (Image, error) {
var image Gif
image.gd = gdCreateFromGif(drain(reader))
if image.gd == nil {
return nil, fmt.Errorf("couldn't create GIF decoder")
}
return &image, nil
}
// EncodeGif encodes the image onto the writer as a GIF.
func EncodeGif(w io.Writer, img Image) (int64, error) {
slice, err := img.image().gdImageGif()
if err != nil {
return 0, err
}
return bytes.NewBuffer(slice).WriteTo(w)
}
Jump to Line
Something went wrong with that request. Please try again.