From d418d63d1a9808a609a4ba5d57ccb6443a4dc0e6 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 --- src/RelImage.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/RelImage.py b/src/RelImage.py index 64c363c0d..3cf03cb64 100644 --- a/src/RelImage.py +++ b/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