diff options
| author | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2020-01-31 14:29:59 +0000 |
|---|---|---|
| committer | Gertjan van den Burg <gertjanvandenburg@gmail.com> | 2020-01-31 14:29:59 +0000 |
| commit | 840de7bbb12f41964388d1488ec5ecdff9b37efd (patch) | |
| tree | e5120c304b97461a8d90d1c5ea09d792e21bdd3c | |
| parent | Remove explicit six dependency (diff) | |
| download | paper2remarkable-840de7bbb12f41964388d1488ec5ecdff9b37efd.tar.gz paper2remarkable-840de7bbb12f41964388d1488ec5ecdff9b37efd.zip | |
Fix cropping bug that results in rotated pages
| -rw-r--r-- | paper2remarkable/crop.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/paper2remarkable/crop.py b/paper2remarkable/crop.py index d1a94d8..5f3b4e3 100644 --- a/paper2remarkable/crop.py +++ b/paper2remarkable/crop.py @@ -139,6 +139,15 @@ class Cropper(object): # This is the bounding box in PIL format: (0, 0) top left x0, y0, x1, y1 = left, top, W - right, H - bottom + # The remarkable changes the orientation of a portrait page if the + # width is greater than the height. To prevent this, we pad the height + # with extra whitespace. This should only occur if the original + # orientation of the page would be changed by cropping. + w, h = x1 - x0, y1 - y0 + if H > W and w > h: + y1 = y0 + w + 10 + h = y1 - y0 + # Get the bbox in Ghostscript format: (0, 0) bottom left a0, b0, a1, b1 = x0, H - y1, x1, H - y0 return [a0, b0, a1, b1] |
