func ParseHTTPRequest(r *http.Request) (*Config, error) {
	query := r.URL.Query()
	widthStr := query.Get("width")
	heightStr := query.Get("height")
	width := 0
	height := 0
	if widthStr != "" {
		var err error
		width, err = strconv.Atoi(widthStr)
		if err != nil {
			return nil, err
		}
	}
	if heightStr != "" {
		var err error
		height, err = strconv.Atoi(heightStr)
		if err != nil {
			return nil, err
		}
	}
	qualityStr := query.Get("quality")
	quality := 0
	if qualityStr != "" {
		var err error
		quality, err = strconv.Atoi(qualityStr)
		if err != nil {
			return nil, err
		}
	}
	return &Config{
		Width:           width,
		Height:          height,
		Quality:         quality,
		ContentTypeFrom: r.Header.Get("content-type"),
		ContentTypeTo:   r.Header.Get("accept"),
	}, nil
}
ParseHTTPRequest parses a http.Request and constructs a Config.
package convert
import (
	"errors"
	"image"
	"image/gif"
	"image/jpeg"
	"image/png"
	"io"
	"net/http"
	"strconv"
	"golang.org/x/image/draw"
)
var ErrUnsupportedContentType = errors.New("unsupported content-type")
type Config struct {
	Width           int
	Height          int
	Quality         int
	ContentTypeFrom string
	ContentTypeTo   string
}