From 486361e71694c9e01ebc723432c4ab83ce42f572 Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 7 Mar 2015 02:59:12 +0100 Subject: [PATCH] cater for python-pil versions without close() attribute --- src/img2pdf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index db8778f..0029481 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -310,7 +310,11 @@ def convert(images, dpi=None, pagesize=(None, None), title=None, author=None, imgdata = imgdata.convert('RGB') color = imgdata.mode img = imgdata.tobytes() - imgdata.close() + # the python-pil version 2.3.0-1ubuntu3 in Ubuntu does not have the close() method + try: + imgdata.close() + except AttributeError: + pass imgdata = zlib.compress(img) im.close()