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

Function CalcCropSize

processing/prepare.go:56–65  ·  view source on GitHub ↗

CalcCropSize calculates the crop size based on the original size and crop scale.

(orig int, crop float64)

Source from the content-addressed store, hash-verified

54
55// CalcCropSize calculates the crop size based on the original size and crop scale.
56func CalcCropSize(orig int, crop float64) int {
57 switch {
58 case crop == 0.0:
59 return 0
60 case crop >= 1.0:
61 return int(crop)
62 default:
63 return max(1, imath.Scale(orig, crop))
64 }
65}
66
67func (c *Context) calcScale(width, height int, po ProcessingOptions) {
68 wshrink, hshrink := 1.0, 1.0

Callers 1

CalcParamsMethod · 0.85

Calls 1

ScaleFunction · 0.92

Tested by

no test coverage detected