Skip to content

Commit 546b527

Browse files
committed
tweak comments
1 parent 87a61db commit 546b527

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@ Installation
2020
node make singlefile
2121
cd ..
2222

23-
## for the renderer
23+
# for the renderer
2424

2525
sudo pip3 install pillow
2626

2727
Running
2828
-------
2929

30-
# Compute the changes.
31-
32-
# Unfortunately the pdf.js prints warnings on STDOUT, so we have
33-
# to filter those out.
30+
Compute the changes (writes a JSON file):
3431

3532
node index.js before.pdf after.pdf | grep -v "^Warning:" > changes.json
3633

37-
# Render the changes.
34+
(Unfortunately the pdf.js library prints warnings on STDOUT, so we have to filter those out.)
35+
36+
Render the changes (turns the PDFs + JSON file into a big PNG image):
3837

3938
python3 render.py < changes.json > test.png
4039

render.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
def pdftopng(pdffile, pagenumber, width=900):
88
pngbytes = subprocess.check_output(["/usr/bin/pdftoppm", "-f", str(pagenumber), "-l", str(pagenumber), "-scale-to", str(width), "-png", pdffile])
99
im = Image.open(io.BytesIO(pngbytes))
10-
return im.convert("RGBA") # greyscale is required by .invert()
10+
return im.convert("RGBA")
1111

1212
# Load all of the pages named in changes.
1313

@@ -20,6 +20,7 @@ def pdftopng(pdffile, pagenumber, width=900):
2020
pages[change["pdf"]["index"]][change["page"]["number"]] = pdftopng(change["pdf"]["file"], change["page"]["number"])
2121

2222
# Draw red boxes around changes.
23+
2324
for change in changes:
2425
if change == "*": continue # not handled yet
2526

@@ -53,7 +54,7 @@ def pdftopng(pdffile, pagenumber, width=900):
5354
# do crop
5455
for pg in pages[idx]:
5556
im = pages[idx][pg]
56-
bbox = ImageOps.invert(im.convert("L")).getbbox()
57+
bbox = ImageOps.invert(im.convert("L")).getbbox() # .invert() requires a grayscale image
5758
vpad = int(.02*im.size[1])
5859
pages[idx][pg] = im.crop( (minx, max(0, bbox[1]-vpad), maxx, min(im.size[1], bbox[3]+vpad) ) )
5960

0 commit comments

Comments
 (0)