Use "with" to open and close input files

main
Ryan C. Thompson 10 years ago
parent b726afbb5a
commit d09cd0f197

@ -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()

Loading…
Cancel
Save