From 4c37fbf724e5b74970be5b47de9bd93c4aff52cb Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 23 May 2001 22:16:19 +0000 Subject: [PATCH] Use python imaging library to do file conversions/scaling if present svn: r52 --- gramps/src/RelImage.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gramps/src/RelImage.py b/gramps/src/RelImage.py index 64c363c0d..3cf03cb64 100644 --- a/gramps/src/RelImage.py +++ b/gramps/src/RelImage.py @@ -29,6 +29,12 @@ import intl _ = intl.gettext +try: + import PIL.Image + no_pil = 0 +except: + no_pil = 1 + #------------------------------------------------------------------------- # # import_photo @@ -40,7 +46,7 @@ def import_photo(filename,path,prefix): type = gnome.mime.type_of_file(filename) if type[0:6] != "image/": - GnomeErrorDialog(_("Currently only JPEG files are supported")) + GnomeErrorDialog(_("Currently only image files are supported")) return None for index in range(0,1000): @@ -53,8 +59,11 @@ def import_photo(filename,path,prefix): if type == "image/jpeg": shutil.copy(filename,name) else: - cmd = const.convert + " " + filename + " " + name - os.system(cmd) + if no_pil: + cmd = "%s %s %s" % (const.convert,filename,name) + os.system(cmd) + else: + PIL.Image.open(filename).save(name) except: return None