本文整理汇总了Golang中github.com/pierrre/imageserver.Params类的典型用法代码示例。如果您正苦于以下问题:Golang Params类的具体用法?Golang Params怎么用?Golang Params使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Params类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getResampling
func (prc *ResizeProcessor) getResampling(params imageserver.Params) (gift.Resampling, error) {
if !params.Has("resampling") {
if prc.DefaultResampling != nil {
return prc.DefaultResampling, nil
}
return gift.NearestNeighborResampling, nil
}
rsp, err := params.GetString("resampling")
if err != nil {
return nil, err
}
switch rsp {
case "nearest_neighbor":
return gift.NearestNeighborResampling, nil
case "box":
return gift.BoxResampling, nil
case "linear":
return gift.LinearResampling, nil
case "cubic":
return gift.CubicResampling, nil
case "lanczos":
return gift.LanczosResampling, nil
}
return nil, &imageserver.ParamError{Param: "resampling", Message: "invalid value"}
}
开发者ID:pierrre,项目名称:imageserver,代码行数:25,代码来源:resize.go
示例2: buildArgumentsMonochrome
func (server *Server) buildArgumentsMonochrome(arguments *list.List, params imageserver.Params) error {
monochrome, _ := params.GetBool("monochrome")
if monochrome {
arguments.PushBack("-monochrome")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:7,代码来源:graphicsmagick.go
示例3: buildArgumentsCrop
func (server *Server) buildArgumentsCrop(arguments *list.List, params imageserver.Params) error {
if !params.Has("crop") {
return nil
}
crop, _ := params.GetString("crop")
cropArgs := strings.Split(crop, ",")
cropArgsLen := len(cropArgs)
if cropArgsLen != 2 && cropArgsLen != 4 {
return &imageserver.ParamError{Param: "crop", Message: "Invalid crop request, parameters number mismatch"}
}
if cropArgsLen == 2 {
width, _ := strconv.Atoi(cropArgs[0])
height, _ := strconv.Atoi(cropArgs[1])
arguments.PushBack("-crop")
arguments.PushBack(fmt.Sprintf("%dx%d", width, height))
arguments.PushBack("+repage")
}
if cropArgsLen == 4 {
width, _ := strconv.Atoi(cropArgs[0])
height, _ := strconv.Atoi(cropArgs[1])
x, _ := strconv.Atoi(cropArgs[2])
y, _ := strconv.Atoi(cropArgs[3])
arguments.PushBack("-crop")
arguments.PushBack(fmt.Sprintf("%dx%d+%d+%d", width, height, x, y))
arguments.PushBack("+repage")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:28,代码来源:graphicsmagick.go
示例4: buildArgumentsFlop
func (server *Server) buildArgumentsFlop(arguments *list.List, params imageserver.Params) error {
flop, _ := params.GetBool("flop")
if flop {
arguments.PushBack("-flop")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:7,代码来源:graphicsmagick.go
示例5: process
func process(nim image.Image, params imageserver.Params) (image.Image, error) {
if params.Empty() {
return nim, nil
}
width, err := getDimension("width", params)
if err != nil {
return nil, err
}
height, err := getDimension("height", params)
if err != nil {
return nil, err
}
if width == 0 && height == 0 {
return nim, nil
}
interp, err := getInterpolation(params)
if err != nil {
return nil, err
}
mode, err := getModeFunc(params)
if err != nil {
return nil, err
}
nim = mode(width, height, nim, interp)
return nim, nil
}
开发者ID:CarverLab,项目名称:imageserver,代码行数:26,代码来源:nfntresize.go
示例6: getInterpolation
func (prc *Processor) getInterpolation(params imageserver.Params) (resize.InterpolationFunction, error) {
if !params.Has("interpolation") {
return prc.DefaultInterpolation, nil
}
interpolation, err := params.GetString("interpolation")
if err != nil {
return 0, err
}
switch interpolation {
case "nearest_neighbor":
return resize.NearestNeighbor, nil
case "bilinear":
return resize.Bilinear, nil
case "bicubic":
return resize.Bicubic, nil
case "mitchell_netravali":
return resize.MitchellNetravali, nil
case "lanczos2":
return resize.Lanczos2, nil
case "lanczos3":
return resize.Lanczos3, nil
default:
return 0, &imageserver.ParamError{Param: "interpolation", Message: "invalid value"}
}
}
开发者ID:cautio,项目名称:imageserver,代码行数:25,代码来源:nfntresize.go
示例7: buildArgumentsGravity
func (server *Server) buildArgumentsGravity(arguments *list.List, params imageserver.Params) error {
gravity, _ := params.GetString("gravity")
var translatedGravity string
if gravity != "" {
switch {
case gravity == "n":
translatedGravity = "North"
case gravity == "s":
translatedGravity = "South"
case gravity == "e":
translatedGravity = "East"
case gravity == "w":
translatedGravity = "West"
case gravity == "ne":
translatedGravity = "NorthEast"
case gravity == "se":
translatedGravity = "SouthEast"
case gravity == "nw":
translatedGravity = "NorthWest"
case gravity == "sw":
translatedGravity = "SouthWest"
}
if translatedGravity == "" {
return &imageserver.ParamError{Param: "gravity", Message: "gravity should n, s, e, w, ne, se, nw or sw"}
}
} else {
// Default gravity is center.
translatedGravity = "Center"
}
arguments.PushBack("-gravity")
arguments.PushBack(fmt.Sprintf("%s", translatedGravity))
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:34,代码来源:graphicsmagick.go
示例8: buildArgumentsGrey
func (server *Server) buildArgumentsGrey(arguments *list.List, params imageserver.Params) error {
grey, _ := params.GetBool("grey")
if grey {
arguments.PushBack("-colorspace")
arguments.PushBack("GRAY")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:8,代码来源:graphicsmagick.go
示例9: buildArgumentsInterlace
func (server *Server) buildArgumentsInterlace(arguments *list.List, params imageserver.Params) error {
interlace, _ := params.GetBool("no_interlace")
if !interlace {
arguments.PushBack("-interlace")
arguments.PushBack("Line")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:8,代码来源:graphicsmagick.go
示例10: buildArgumentsTrim
func (server *Server) buildArgumentsTrim(arguments *list.List, params imageserver.Params) error {
trim, _ := params.GetBool("trim")
if trim {
// We must execute trim first. (order of operations)
arguments.PushFront("-trim")
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:8,代码来源:graphicsmagick.go
示例11: Get
// Get implements imageserver.Server.
func (s *Server) Get(params imageserver.Params) (*imageserver.Image, error) {
src, err := params.Get(Param)
if err != nil {
return nil, err
}
params = imageserver.Params{Param: src}
return s.Server.Get(params)
}
开发者ID:pierrre,项目名称:imageserver,代码行数:9,代码来源:source.go
示例12: getPath
func (srv *Server) getPath(params imageserver.Params) (string, error) {
src, err := params.GetString(imageserver_source.Param)
if err != nil {
return "", err
}
// This trick comes from net/http.Dir.Open().
// It allows to "jail" the path inside the root.
return filepath.Join(srv.Root, filepath.FromSlash(path.Clean("/"+src))), nil
}
开发者ID:pierrre,项目名称:imageserver,代码行数:9,代码来源:file.go
示例13: TestParseQueryStringUndefined
func TestParseQueryStringUndefined(t *testing.T) {
req, err := http.NewRequest("GET", "http://localhost", nil)
if err != nil {
t.Fatal(err)
}
params := imageserver.Params{}
ParseQueryString("string", req, params)
if params.Has("string") {
t.Fatal("should not be set")
}
}
开发者ID:cautio,项目名称:imageserver,代码行数:11,代码来源:parser_test.go
示例14: ParseQueryFloat
// ParseQueryFloat takes the param from the query string, parse it as a float64 and add it to params.
func ParseQueryFloat(param string, req *http.Request, params imageserver.Params) error {
s := req.URL.Query().Get(param)
if s == "" {
return nil
}
f, err := strconv.ParseFloat(s, 64)
if err != nil {
return newParseTypeParamError(param, "float", err)
}
params.Set(param, f)
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:13,代码来源:parser.go
示例15: buildArgumentsRotate
func (server *Server) buildArgumentsRotate(arguments *list.List, params imageserver.Params) error {
rotate, _ := params.GetInt("rotate")
if rotate != 0 {
if rotate < 0 || rotate > 359 {
return &imageserver.ParamError{Param: "rotate", Message: "Invalid rotate parameter"}
}
arguments.PushBack("-rotate")
arguments.PushBack(strconv.Itoa(rotate))
}
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:12,代码来源:graphicsmagick.go
示例16: ParseQueryInt
// ParseQueryInt takes the param from the query string, parse it as an int and add it to params.
func ParseQueryInt(param string, req *http.Request, params imageserver.Params) error {
s := req.URL.Query().Get(param)
if s == "" {
return nil
}
i, err := strconv.Atoi(s)
if err != nil {
return newParseTypeParamError(param, "int", err)
}
params.Set(param, i)
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:13,代码来源:parser.go
示例17: ParseQueryBool
// ParseQueryBool takes the param from the query string, parse it as an bool and add it to params.
func ParseQueryBool(param string, req *http.Request, params imageserver.Params) error {
s := req.URL.Query().Get(param)
if s == "" {
return nil
}
b, err := strconv.ParseBool(s)
if err != nil {
return newParseTypeParamError(param, "bool", err)
}
params.Set(param, b)
return nil
}
开发者ID:phamhongviet,项目名称:imageserver,代码行数:13,代码来源:parser.go
示例18: getDimension
func getDimension(name string, params imageserver.Params) (int, error) {
if !params.Has(name) {
return 0, nil
}
dimension, err := params.GetInt(name)
if err != nil {
return 0, err
}
if dimension < 0 {
return 0, &imageserver.ParamError{Param: name, Message: "must be greater than or equal to 0"}
}
return dimension, nil
}
开发者ID:pierrre,项目名称:imageserver,代码行数:13,代码来源:graphicsmagick.go
示例19: Get
// Get implements Server.
func (srv *ValidateParamsServer) Get(params imageserver.Params) (*imageserver.Image, error) {
if params.Has(Param) {
params, err := params.GetParams(Param)
if err != nil {
return nil, err
}
err = srv.validate(params)
if err != nil {
return nil, wrapParamError(err)
}
}
return srv.Server.Get(params)
}
开发者ID:CarverLab,项目名称:imageserver,代码行数:14,代码来源:validate.go
示例20: Parse
// Parse implements Parser.
func (parser *Parser) Parse(req *http.Request, params imageserver.Params) error {
p := imageserver.Params{}
err := parse(req, p)
if err != nil {
if err, ok := err.(*imageserver.ParamError); ok {
err.Param = Param + "." + err.Param
}
return err
}
if !p.Empty() {
params.Set(Param, p)
}
return nil
}
开发者ID:cautio,项目名称:imageserver,代码行数:15,代码来源:nfntresize.go
注:本文中的github.com/pierrre/imageserver.Params类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论