Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (28 sloc) 654 Bytes
package mogrify
import (
// Png image that can be transformed.
type Png struct {
// Embed GdImage and all it's methods
// DecodePng decodes a PNG image from a reader.
func DecodePng(reader io.Reader) (Image, error) {
var image Png = gdCreateFromPng(drain(reader))
if == nil {
return nil, fmt.Errorf("couldn't create PNG decoder")
return &image, nil
// EncodePng encodes the image onto the writer as a PNG.
func EncodePng(w io.Writer, img Image) (int64, error) {
slice, err := img.image().gdImagePng()
if err != nil {
return 0, err
return bytes.NewBuffer(slice).WriteTo(w)