1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00
imgproxy/utils.go

41 lines
460 B
Go
Raw Normal View History

2018-09-11 13:23:28 +02:00
package main
import "math"
2018-09-11 13:23:28 +02:00
func maxInt(a, b int) int {
if a > b {
return a
}
return b
}
func minInt(a, b int) int {
if a < b {
return a
}
return b
}
2019-09-11 12:40:07 +02:00
func minNonZeroInt(a, b int) int {
switch {
case a == 0:
return b
case b == 0:
return a
}
return minInt(a, b)
}
func roundToInt(a float64) int {
return int(math.Round(a))
}
2019-09-11 12:40:07 +02:00
func scaleInt(a int, scale float64) int {
if a == 0 {
return 0
}
return roundToInt(float64(a) * scale)
}