Support the ability to make images square

This commit is contained in:
Jacob Gunther
2024-07-13 11:45:16 -05:00
parent ae3203543a
commit e123b0e337
7 changed files with 22 additions and 1 deletions

View File

@@ -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())
}

View File

@@ -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"`
}

View File

@@ -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,
}
)

View File

@@ -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),
}
}