Support the ability to make images square
This commit is contained in:
@@ -22,6 +22,7 @@ func GetResultCacheKey(uuid, renderType string, opts *QueryParams) string {
|
||||
values.Set("scale", strconv.FormatInt(int64(opts.Scale), 10))
|
||||
values.Set("overlay", strconv.FormatBool(opts.Overlay))
|
||||
values.Set("format", opts.Format)
|
||||
values.Set("square", strconv.FormatBool(opts.Square))
|
||||
|
||||
return SHA256(values.Encode())
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -27,6 +28,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -35,6 +37,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -43,6 +46,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -51,6 +55,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -59,6 +64,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -67,6 +73,7 @@ var (
|
||||
DefaultOverlay: true,
|
||||
DefaultDownload: false,
|
||||
DefaultScale: 4,
|
||||
DefaultSquare: false,
|
||||
MinScale: 1,
|
||||
MaxScale: 64,
|
||||
DefaultFormat: "png",
|
||||
@@ -112,6 +119,7 @@ type RouteConfig struct {
|
||||
DefaultOverlay bool `yaml:"default_overlay"`
|
||||
DefaultDownload bool `yaml:"default_download"`
|
||||
DefaultFormat string `yaml:"default_format"`
|
||||
DefaultSquare bool `yaml:"default_square"`
|
||||
MinScale int `yaml:"min_scale"`
|
||||
MaxScale int `yaml:"max_scale"`
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ func Render(renderType, uuid string, rawSkin *image.NRGBA, isSlim bool, opts *Qu
|
||||
Overlay: opts.Overlay,
|
||||
Slim: isSlim,
|
||||
Scale: opts.Scale,
|
||||
Square: opts.Square,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ type QueryParams struct {
|
||||
Download bool
|
||||
Overlay bool
|
||||
Format string
|
||||
Square bool
|
||||
}
|
||||
|
||||
// PointerOf returns the value of the first argument as a pointer.
|
||||
@@ -278,6 +279,7 @@ func ParseQueryParams(ctx *fiber.Ctx, route RouteConfig) *QueryParams {
|
||||
Download: ctx.QueryBool("download", route.DefaultDownload),
|
||||
Overlay: ctx.QueryBool("overlay", route.DefaultOverlay),
|
||||
Format: ctx.Query("format", route.DefaultFormat),
|
||||
Square: ctx.QueryBool("square", route.DefaultSquare),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user