Apply rotation for the web preview PNG. The web preview should match what the user physically sees on the display. * 0° – landscape, show as-is * 90° – portrait, show as-is (getbuffer + physical mount cancel) * 180° – landscape upside-down * 270° – portrait upside-down (getbu
(image, rotation)
| 66 | |
| 67 | |
| 68 | # Map rotation angle → PIL transpose operation |
| 69 | _ROTATION_TRANSPOSE = { |
| 70 | 90: Image.Transpose.ROTATE_90, |
| 71 | 180: Image.Transpose.ROTATE_180, |
| 72 | 270: Image.Transpose.ROTATE_270, |
| 73 | } |
| 74 | |
| 75 | |
| 76 | def _render_dimensions(width, height, rotation): |
| 77 | """Return (render_w, render_h) for the given rotation. |
| 78 | |
| 79 | For 90°/270° the render canvas is portrait (swapped) so that the |
| 80 | e-paper getbuffer 'Vertical' path maps it correctly to the landscape |
| 81 | display buffer. For 0°/180° dimensions stay as-is. |
| 82 | """ |