MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / NewGravityOptions

Function NewGravityOptions

processing/gravity.go:68–76  ·  view source on GitHub ↗

NewGravityOptions builds a new [GravityOptions] instance. It fills the [GravityOptions] struct with the options values under the given prefix. If the gravity type is not set in the options, it returns a [GravityOptions] with the provided default type.

(o *options.Options, prefix string, defType GravityType)

Source from the content-addressed store, hash-verified

66// If the gravity type is not set in the options,
67// it returns a [GravityOptions] with the provided default type.
68func NewGravityOptions(o *options.Options, prefix string, defType GravityType) GravityOptions {
69 gr := GravityOptions{
70 Type: options.Get(o, prefix+keys.SuffixType, defType),
71 X: o.GetFloat(prefix+keys.SuffixXOffset, 0.0),
72 Y: o.GetFloat(prefix+keys.SuffixYOffset, 0.0),
73 }
74
75 return gr
76}
77
78// RotateAndFlip rotates and flips the gravity options so that they correspond
79// to the image before rotation and flipping.

Callers 4

GravityMethod · 0.85
ExtendGravityMethod · 0.85
CropGravityMethod · 0.85

Calls 2

GetFunction · 0.92
GetFloatMethod · 0.80

Tested by

no test coverage detected