MCPcopy
hub / github.com/willnorris/imageproxy / evaluateFloat

Function evaluateFloat

transform.go:134–142  ·  view source on GitHub ↗

evaluateFloat interprets the option value f. If f is between 0 and 1, it is interpreted as a percentage of max, otherwise it is treated as an absolute value. If f is less than 0, 0 is returned.

(f float64, max int)

Source from the content-addressed store, hash-verified

132// interpreted as a percentage of max, otherwise it is treated as an absolute
133// value. If f is less than 0, 0 is returned.
134func evaluateFloat(f float64, max int) int {
135 if 0 < f && f < 1 {
136 return int(float64(max) * f)
137 }
138 if f < 0 {
139 return 0
140 }
141 return int(f)
142}
143
144// resizeParams determines if the image needs to be resized, and if so, the
145// dimensions to resize to.

Callers 2

resizeParamsFunction · 0.85
cropParamsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected