Skip to content

Commit c4775c3

Browse files
committed
allow for disabling horizontal zealous cropping
1 parent 20b109b commit c4775c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pdf-diff.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/python3
22

3-
import sys, json, subprocess, io
3+
import sys, json, subprocess, io, os
44
from lxml import etree
55
from PIL import Image, ImageDraw, ImageOps
66

@@ -296,7 +296,10 @@ def zealous_crop(page_groups):
296296
bbox = ImageOps.invert(im.convert("L")).getbbox() # .invert() requires a grayscale image
297297
if bbox is None: bbox = [0, 0, im.size[0], im.size[1]] # empty page
298298
vpad = int(.02*im.size[1])
299-
grp[idx][pg] = im.crop( (minx, max(0, bbox[1]-vpad), maxx, min(im.size[1], bbox[3]+vpad) ) )
299+
im = im.crop( (0, max(0, bbox[1]-vpad), im.size[0], min(im.size[1], bbox[3]+vpad) ) )
300+
if os.environ.get("HORZCROP") != "0":
301+
im = im.crop( (minx, 0, maxx, im.size[1]) )
302+
grp[idx][pg] = im
300303

301304
def stack_pages(page_groups):
302305
# Compute the dimensions of the final image.

0 commit comments

Comments
 (0)