29 lines
544 B
Python
29 lines
544 B
Python
import errno, os, PIL, fpdf
|
|
|
|
JPG = 0
|
|
PNG = 1
|
|
|
|
def makeDir(issue):
|
|
try:
|
|
os.makedirs(str(issue))
|
|
return True
|
|
|
|
except OSError as e:
|
|
if e.errno != errno.EEXIST:
|
|
raise
|
|
|
|
return False
|
|
|
|
def makePDF(issue, pages, type = JPG):
|
|
ext = "jpg" if type == JPG else "png"
|
|
cover = PIL.Image.open("%s/1.%s" % (str(issue), ext))
|
|
x, y = cover.size
|
|
|
|
pdf = fpdf.FPDF(unit = "pt", format = [x, y])
|
|
|
|
for page in range(pages):
|
|
pdf.add_page()
|
|
pdf.image("%s/%i.%s" % (str(issue), page + 1, ext), 0, 0)
|
|
|
|
pdf.output("%s/issue.pdf" % str(issue), "F")
|
|
|