示例#1
0
func (parser *Parser) parse(req *http.Request, params imageserver.Params) error {
	if err := imageserver_http.ParseQueryInt("width", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryInt("height", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryBool("fill", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryBool("ignore_ratio", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryBool("only_shrink_larger", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryBool("only_enlarge_smaller", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryBool("extent", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryInt("quality", req, params); err != nil {
		return err
	}
	imageserver_http.ParseQueryString("background", req, params)
	imageserver_http.ParseQueryString("format", req, params)
	return nil
}
示例#2
0
func (prs *RotateParser) parse(req *http.Request, params imageserver.Params) error {
	if err := imageserver_http.ParseQueryFloat("rotation", req, params); err != nil {
		return err
	}
	imageserver_http.ParseQueryString("background", req, params)
	imageserver_http.ParseQueryString("interpolation", req, params)
	return nil
}
示例#3
0
func parse(req *http.Request, params imageserver.Params) error {
	if err := imageserver_http.ParseQueryInt("width", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryInt("height", req, params); err != nil {
		return err
	}
	imageserver_http.ParseQueryString("interpolation", req, params)
	imageserver_http.ParseQueryString("mode", req, params)
	return nil
}
示例#4
0
func (prs *ResizeParser) parse(req *http.Request, params imageserver.Params) error {
	if err := imageserver_http.ParseQueryInt("width", req, params); err != nil {
		return err
	}
	if err := imageserver_http.ParseQueryInt("height", req, params); err != nil {
		return err
	}
	imageserver_http.ParseQueryString("resampling", req, params)
	imageserver_http.ParseQueryString("mode", req, params)
	return nil
}
func (parser *Parser) parse(req *http.Request, params imageserver.Params) error {
	// parse bool params
	boolParams := []string{
		"ignore_ratio",
		"fill",
		"only_shrink_larger",
		"only_enlarge_smaller",
		"extent",
		"monochrome",
		"grey",
		"no_strip",
		"trim",
		"no_interlace",
		"flip",
		"flop",
	}
	for _, bp := range boolParams {
		err := imageserver_http.ParseQueryBool(bp, req, params)
		if err != nil {
			return err
		}
	}

	// parse integer params
	intParams := []string{
		"w",
		"h",
		"rotate",
		"q",
	}
	for _, ip := range intParams {
		err := imageserver_http.ParseQueryInt(ip, req, params)
		if err != nil {
			return err
		}
	}

	// parse string params
	stringParams := []string{
		"bg",
		"gravity",
		"crop",
		"format",
	}
	for _, sp := range stringParams {
		imageserver_http.ParseQueryString(sp, req, params)
	}
	return nil
}
示例#6
0
// Parse implements Parser.
func (parser *FormatParser) Parse(req *http.Request, params imageserver.Params) error {
	imageserver_http.ParseQueryString("format", req, params)
	if !params.Has("format") {
		return nil
	}
	format, err := params.GetString("format")
	if err != nil {
		return err
	}
	if format == "jpg" {
		format = "jpeg"
	}
	params.Set("format", format)
	return nil
}