Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 35 lines (33 sloc) 1.17 KB
import pyPdf, sys, os
from PIL import Image, ImageEnhance
from pyPdf import PdfFileWriter, PdfFileReader
if len(sys.argv) == 1:
print "USAGE: makePdf folder_name"
path = sys.argv[1]+"/"
output = PdfFileWriter()
images = os.listdir(path)
# Set the key here based on what we are using to order the images
images = sorted(images, key=lambda x: int(x.split('.')[0]))
for i in images: # Create temporary images and save them as pdfs
imagePath = path+i
print imagePath
tempImagePath = imagePath+".temp"
img =
sharpener = ImageEnhance.Sharpness(img)
img = sharpener.enhance(1.5)
if "RT90" in tempImagePath:
img = img.rotate(-90)
elif "LT90" in tempImagePath:
img = img.rotate(90)
elif "UT180" in tempImagePath:
img = img.rotate(180), "PDF", resolution=100.0)
inputConvertedImage = PdfFileReader(file(tempImagePath, "rb"))
outputStream = file("output.pdf", "wb")
for i in images: #Delete all the temporary pdf files created