angleFlip returns the orientation angle and flip flag based on the image metadata and po.AutoRotate flag.
(img *vips.Image, autoRotate bool)
| 24 | // angleFlip returns the orientation angle and flip flag based on the image metadata |
| 25 | // and po.AutoRotate flag. |
| 26 | func 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. |
| 56 | func CalcCropSize(orig int, crop float64) int { |
no test coverage detected