Skip to content
Newer
Older
100644 32 lines (24 sloc) 465 Bytes
8c4321f @tobi Complete encoding/decoding for the three major formats
authored May 29, 2012
1 package mogrify
2
3 import (
4 "bytes"
5 "io"
6 )
7
8 type Png struct {
9 // Import GdImage and all it's methods
10 GdImage
11 }
12
13 func DecodePng(reader io.Reader) Image {
14 var image Png
15
16 image.gd = gdCreateFromPng(drain(reader))
17 if image.gd == nil {
18 return nil
19 }
20
21 return &image
22 }
23
24 func EncodePng(w io.Writer, img Image) (int64, error) {
25 slice, err := img.image().gdImagePng()
26 if err != nil {
27 return 0, err
28 }
29
30 return bytes.NewBuffer(slice).WriteTo(w)
31 }
Something went wrong with that request. Please try again.