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

Function angleFlip

processing/prepare.go:26–53  ·  view source on GitHub ↗

angleFlip returns the orientation angle and flip flag based on the image metadata and po.AutoRotate flag.

(img *vips.Image, autoRotate bool)

Source from the content-addressed store, hash-verified

24// angleFlip returns the orientation angle and flip flag based on the image metadata
25// and po.AutoRotate flag.
26func angleFlip(img *vips.Image, autoRotate bool) (int, bool) {
27 if !autoRotate {
28 return 0, false
29 }
30
31 angle := 0
32 flip := false
33
34 orientation := img.Orientation()
35
36 if orientation == 3 || orientation == 4 {
37 angle = 180
38 }
39
40 if orientation == 5 || orientation == 6 {
41 angle = 90
42 }
43
44 if orientation == 7 || orientation == 8 {
45 angle = 270
46 }
47
48 if orientation == 2 || orientation == 4 || orientation == 5 || orientation == 7 {
49 flip = true
50 }
51
52 return angle, flip
53}
54
55// CalcCropSize calculates the crop size based on the original size and crop scale.
56func CalcCropSize(orig int, crop float64) int {

Callers 1

ExtractGeometryFunction · 0.85

Calls 1

OrientationMethod · 0.80

Tested by

no test coverage detected