Move makePDF() to pdftools
This commit is contained in:
parent
c8707c155e
commit
40e2788b2b
16
falter.py
16
falter.py
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import errno, fpdf, os, os.path, PIL, urllib.request
|
||||
import errno, fpdf, os, os.path, pdftools, PIL, urllib.request
|
||||
|
||||
def getPage(issue, page):
|
||||
try:
|
||||
|
@ -23,18 +23,6 @@ def makeDir(issue):
|
|||
|
||||
return False
|
||||
|
||||
def makePDF(issue, pages):
|
||||
cover = PIL.Image.open("%i/1.jpg" % issue)
|
||||
x, y = cover.size
|
||||
|
||||
pdf = fpdf.FPDF(unit = "pt", format = [x, y])
|
||||
|
||||
for page in range(pages):
|
||||
pdf.add_page()
|
||||
pdf.image("%i/%i.jpg" % (issue, page + 1), 0, 0)
|
||||
|
||||
pdf.output("%i/issue.pdf" % issue, "F")
|
||||
|
||||
def getIssue(issue, makepdf = True):
|
||||
if makeDir(issue):
|
||||
i = 1
|
||||
|
@ -50,7 +38,7 @@ def getIssue(issue, makepdf = True):
|
|||
print("[NOTICE] Incomplete issue: %i" % issue)
|
||||
|
||||
if makepdf:
|
||||
makePDF(issue, i-1)
|
||||
pdftools.makePDF(issue, i-1)
|
||||
|
||||
else:
|
||||
print("[NOTICE] Skipping issue: %i (already exists)" % issue)
|
||||
|
|
12
pdftools/__init__.py
Normal file
12
pdftools/__init__.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
def makePDF(issue, pages):
|
||||
cover = PIL.Image.open("%i/1.jpg" % issue)
|
||||
x, y = cover.size
|
||||
|
||||
pdf = fpdf.FPDF(unit = "pt", format = [x, y])
|
||||
|
||||
for page in range(pages):
|
||||
pdf.add_page()
|
||||
pdf.image("%i/%i.jpg" % (issue, page + 1), 0, 0)
|
||||
|
||||
pdf.output("%i/issue.pdf" % issue, "F")
|
||||
|
Loading…
Reference in a new issue