1
0
Fork 0
forked from josch/img2pdf

Use "with" to open and close input files

This commit is contained in:
Ryan C. Thompson 2014-11-06 00:53:16 -08:00
parent b726afbb5a
commit d09cd0f197

View file

@ -206,7 +206,7 @@ def convert(images, dpi, x, y, title=None, author=None, creator=None, producer=N
for imfilename in images:
debug_out("Reading %s"%imfilename, verbose)
im = open(imfilename, "rb")
with open(imfilename, "rb") as im:
rawdata = im.read()
im.seek(0)
try:
@ -286,8 +286,6 @@ def convert(images, dpi, x, y, title=None, author=None, creator=None, producer=N
pdf.addimage(color, width, height, imgformat, imgdata, pdf_x, pdf_y)
im.close()
return pdf.tostring()