func Encode(w io.Writer, m image.Image, opt *Options) (err error) {
	var output []byte
	if opt != nil && opt.Lossless {
		switch m := adjustImage(m).(type) {
		case *image.Gray:
			if output, err = EncodeLosslessGray(m); err != nil {
				return
			}
		case *_RGB:
			if output, err = EncodeLosslessRGB(m); err != nil {
				return
			}
		case *image.RGBA:
			if output, err = EncodeLosslessRGBA(m); err != nil {
				return
			}
		default:
			panic("image/webp: Encode, unreachable!")
		}
	} else {
		quality := float32(DefaulQuality)
		if opt != nil {
			quality = opt.Quality
		}
		switch m := adjustImage(m).(type) {
		case *image.Gray:
			if output, err = EncodeGray(m, quality); err != nil {
				return
			}
		case *_RGB:
			if output, err = EncodeRGB(m, quality); err != nil {
				return
			}
		case *image.RGBA:
			if output, err = EncodeRGBA(m, quality); err != nil {
				return
			}
		default:
			panic("image/webp: Encode, unreachable!")
		}
	}
	_, err = w.Write(output)
	return
}
// Encode writes the image m to w in WEBP format.
Encode writes the image m to w in WEBP format.
// Encode writes the image m to w in WEBP format .
func Encode(w io.Writer, m image.Image, opt *Options) (err error) {
	var output []byte
	if opt != nil && opt.Lossless {
		switch m := adjustImage(m).(type) {
		case *image.Gray:
			if output, err = EncodeLosslessGray(m); err != nil {
				return
			}
		case *_RGB:
			if output, err = EncodeLosslessRGB(m); err != nil {
				return
			}
		case *image.RGBA:
			if output, err = EncodeLosslessRGBA(m); err != nil {
				return
			}
		default:
			panic("image/webp: Encode, unreachable!")
		}
	} else {
		quality := float32(DefaulQuality)
		if opt != nil {
			quality = opt.Quality
		}
		switch m := adjustImage(m).(type) {
		case *image.Gray:
			if output, err = EncodeGray(m, quality); err != nil {
				return
			}
		case *_RGB:
			if output, err = EncodeRGB(m, quality); err != nil {
				return
			}
		case *image.RGBA:
			if output, err = EncodeRGBA(m, quality); err != nil {
				return
			}
		default:
			panic("image/webp: Encode, unreachable!")
		}
	}
	_, err = w.Write(output)
	return
}
func Encode ( w io . Writer , m image . Image , opt * Options ) ( err error ) { var output [ ] byte if opt != nil && opt . Lossless { switch m := adjustImage ( m ) . ( type ) { case * image . Gray : if output , err = EncodeLosslessGray ( m ) ; err != nil { return } case * _RGB : if output , err = EncodeLosslessRGB ( m ) ; err != nil { return } case * image . RGBA : if output , err = EncodeLosslessRGBA ( m ) ; err != nil { return } default : panic ( " " ) } } else { quality := float32 ( DefaulQuality ) if opt != nil { quality = opt . Quality } switch m := adjustImage ( m ) . ( type ) { case * image . Gray : if output , err = EncodeGray ( m , quality ) ; err != nil { return } case * _RGB : if output , err = EncodeRGB ( m , quality ) ; err != nil { return } case * image . RGBA : if output , err = EncodeRGBA ( m , quality ) ; err != nil { return } default : panic ( " " ) } } _ , err = w . Write ( output ) return }
Encode writes the image m to w in WEBP format.
Encode writes the image m to w in WEBP format .