(img, degrees, **kwargs)
| 86 | |
| 87 | |
| 88 | def rotate(img, degrees, **kwargs): |
| 89 | _check_args_tf(kwargs) |
| 90 | if _PIL_VER >= (5, 2): |
| 91 | return img.rotate(degrees, **kwargs) |
| 92 | elif _PIL_VER >= (5, 0): |
| 93 | w, h = img.size |
| 94 | post_trans = (0, 0) |
| 95 | rotn_center = (w / 2.0, h / 2.0) |
| 96 | angle = -math.radians(degrees) |
| 97 | matrix = [ |
| 98 | round(math.cos(angle), 15), |
| 99 | round(math.sin(angle), 15), |
| 100 | 0.0, |
| 101 | round(-math.sin(angle), 15), |
| 102 | round(math.cos(angle), 15), |
| 103 | 0.0, |
| 104 | ] |
| 105 | |
| 106 | def transform(x, y, matrix): |
| 107 | (a, b, c, d, e, f) = matrix |
| 108 | return a * x + b * y + c, d * x + e * y + f |
| 109 | |
| 110 | matrix[2], matrix[5] = transform( |
| 111 | -rotn_center[0] - post_trans[0], -rotn_center[1] - post_trans[1], matrix |
| 112 | ) |
| 113 | matrix[2] += rotn_center[0] |
| 114 | matrix[5] += rotn_center[1] |
| 115 | return img.transform(img.size, Image.AFFINE, matrix, **kwargs) |
| 116 | else: |
| 117 | return img.rotate(degrees, resample=kwargs['resample']) |
| 118 | |
| 119 | |
| 120 | def auto_contrast(img, **__): |
nothing calls this directly
no test coverage detected