Support the ability to make images square
This commit is contained in:
@@ -8,6 +8,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
head:
|
head:
|
||||||
@@ -15,6 +16,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
full_body:
|
full_body:
|
||||||
@@ -22,6 +24,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
front_body:
|
front_body:
|
||||||
@@ -29,6 +32,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
back_body:
|
back_body:
|
||||||
@@ -36,6 +40,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
left_body:
|
left_body:
|
||||||
@@ -43,6 +48,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
right_body:
|
right_body:
|
||||||
@@ -50,6 +56,7 @@ routes:
|
|||||||
default_download: false
|
default_download: false
|
||||||
default_scale: 4
|
default_scale: 4
|
||||||
default_format: png
|
default_format: png
|
||||||
|
default_square: false
|
||||||
min_scale: 1
|
min_scale: 1
|
||||||
max_scale: 64
|
max_scale: 64
|
||||||
raw_skin:
|
raw_skin:
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -5,7 +5,7 @@ go 1.18
|
|||||||
require (
|
require (
|
||||||
github.com/go-redsync/redsync/v4 v4.12.1
|
github.com/go-redsync/redsync/v4 v4.12.1
|
||||||
github.com/gofiber/fiber/v2 v2.52.2
|
github.com/gofiber/fiber/v2 v2.52.2
|
||||||
github.com/mineatar-io/skin-render v1.2.0
|
github.com/mineatar-io/skin-render v1.3.0
|
||||||
github.com/redis/go-redis/v9 v9.5.1
|
github.com/redis/go-redis/v9 v9.5.1
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|||||||
2
go.sum
2
go.sum
@@ -41,6 +41,8 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
|
|||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mineatar-io/skin-render v1.2.0 h1:0lGe8epVbeqnDMnj7EleKZeoQBA3k5WVMIm8UE8fF+g=
|
github.com/mineatar-io/skin-render v1.2.0 h1:0lGe8epVbeqnDMnj7EleKZeoQBA3k5WVMIm8UE8fF+g=
|
||||||
github.com/mineatar-io/skin-render v1.2.0/go.mod h1:ESYvjLHUilplx/WhI3fNCfbvAGhiPL0kC273tIdZ8WA=
|
github.com/mineatar-io/skin-render v1.2.0/go.mod h1:ESYvjLHUilplx/WhI3fNCfbvAGhiPL0kC273tIdZ8WA=
|
||||||
|
github.com/mineatar-io/skin-render v1.3.0 h1:xLDBmTjPaq+g+EvsyLxlY66lK63UQ86aYUu1FY1U7ZM=
|
||||||
|
github.com/mineatar-io/skin-render v1.3.0/go.mod h1:ESYvjLHUilplx/WhI3fNCfbvAGhiPL0kC273tIdZ8WA=
|
||||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
|
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
|
||||||
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ func GetResultCacheKey(uuid, renderType string, opts *QueryParams) string {
|
|||||||
values.Set("scale", strconv.FormatInt(int64(opts.Scale), 10))
|
values.Set("scale", strconv.FormatInt(int64(opts.Scale), 10))
|
||||||
values.Set("overlay", strconv.FormatBool(opts.Overlay))
|
values.Set("overlay", strconv.FormatBool(opts.Overlay))
|
||||||
values.Set("format", opts.Format)
|
values.Set("format", opts.Format)
|
||||||
|
values.Set("square", strconv.FormatBool(opts.Square))
|
||||||
|
|
||||||
return SHA256(values.Encode())
|
return SHA256(values.Encode())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -27,6 +28,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -35,6 +37,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -43,6 +46,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -51,6 +55,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -59,6 +64,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -67,6 +73,7 @@ var (
|
|||||||
DefaultOverlay: true,
|
DefaultOverlay: true,
|
||||||
DefaultDownload: false,
|
DefaultDownload: false,
|
||||||
DefaultScale: 4,
|
DefaultScale: 4,
|
||||||
|
DefaultSquare: false,
|
||||||
MinScale: 1,
|
MinScale: 1,
|
||||||
MaxScale: 64,
|
MaxScale: 64,
|
||||||
DefaultFormat: "png",
|
DefaultFormat: "png",
|
||||||
@@ -112,6 +119,7 @@ type RouteConfig struct {
|
|||||||
DefaultOverlay bool `yaml:"default_overlay"`
|
DefaultOverlay bool `yaml:"default_overlay"`
|
||||||
DefaultDownload bool `yaml:"default_download"`
|
DefaultDownload bool `yaml:"default_download"`
|
||||||
DefaultFormat string `yaml:"default_format"`
|
DefaultFormat string `yaml:"default_format"`
|
||||||
|
DefaultSquare bool `yaml:"default_square"`
|
||||||
MinScale int `yaml:"min_scale"`
|
MinScale int `yaml:"min_scale"`
|
||||||
MaxScale int `yaml:"max_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,
|
Overlay: opts.Overlay,
|
||||||
Slim: isSlim,
|
Slim: isSlim,
|
||||||
Scale: opts.Scale,
|
Scale: opts.Scale,
|
||||||
|
Square: opts.Square,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ type QueryParams struct {
|
|||||||
Download bool
|
Download bool
|
||||||
Overlay bool
|
Overlay bool
|
||||||
Format string
|
Format string
|
||||||
|
Square bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// PointerOf returns the value of the first argument as a pointer.
|
// 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),
|
Download: ctx.QueryBool("download", route.DefaultDownload),
|
||||||
Overlay: ctx.QueryBool("overlay", route.DefaultOverlay),
|
Overlay: ctx.QueryBool("overlay", route.DefaultOverlay),
|
||||||
Format: ctx.Query("format", route.DefaultFormat),
|
Format: ctx.Query("format", route.DefaultFormat),
|
||||||
|
Square: ctx.QueryBool("square", route.DefaultSquare),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user