From 3c6eee59c865a827914400cee27f8dead3c8a3a6 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 23 May 2001 22:14:53 +0000 Subject: [PATCH] Use the python image library to do image conversions if it is present svn: r51 --- src/AbiWordDoc.py | 18 ++++++++++++++++-- src/EditPerson.py | 14 +++++--------- src/OpenOfficeDoc.py | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/AbiWordDoc.py b/src/AbiWordDoc.py index 38b4073b2..d1f1fc0c8 100644 --- a/src/AbiWordDoc.py +++ b/src/AbiWordDoc.py @@ -26,6 +26,13 @@ from latin_utf8 import latin_to_utf8 import const import string +try: + import PIL + no_pil = 0 +except: + no_pil = 1 + + class AbiWordDoc(TextDoc): def __init__(self,type,orientation): @@ -70,8 +77,15 @@ class AbiWordDoc(TextDoc): height = file_tuple[2] base = "/tmp/%s.png" % os.path.basename(file) tag = string.replace(base,'.','_') - cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,base) - os.system(cmd) + + if no_pil: + cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,base) + os.system(cmd) + else: + im = PIL.Image.open(file) + im.thumbnail((width,height)) + im.save(base,"PNG") + self.f.write('\n') diff --git a/src/EditPerson.py b/src/EditPerson.py index a63914074..c6361376d 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -324,8 +324,7 @@ class EditPerson: for address in self.person.getAddressList(): location = address.getCity() + " " + address.getState() + " " + \ address.getCountry() - self.address_list.append([address.getStartDate(),\ - address.getStopDate(),location]) + self.address_list.append([address.getDate(),location]) self.address_list.set_row_data(self.address_index,address) self.address_index = self.address_index + 1 @@ -478,8 +477,7 @@ def on_address_list_select_row(obj,row,b,c): edit_person_obj = obj.get_data(EDITPERSON) address = obj.get_row_data(row) - edit_person_obj.address_start.set_text(address.getStartDate()) - edit_person_obj.address_stop.set_text(address.getStopDate()) + edit_person_obj.address_start.set_text(address.getDate()) edit_person_obj.address_street.set_text(address.getStreet()) edit_person_obj.address_city.set_text(address.getCity()) edit_person_obj.address_state.set_text(address.getState()) @@ -553,8 +551,7 @@ def on_update_address_clicked(obj): edit_person_obj = obj.get_data(EDITPERSON) address = obj.get_row_data(row) - address.setStartDate(edit_person_obj.address_start.get_text()) - address.setStopDate(edit_person_obj.address_stop.get_text()) + address.setDate(edit_person_obj.address_start.get_text()) address.setStreet(edit_person_obj.address_street.get_text()) address.setCity(edit_person_obj.address_city.get_text()) address.setState(edit_person_obj.address_state.get_text()) @@ -703,8 +700,7 @@ def on_add_address_clicked(obj): edit_person_obj = obj.get_data(EDITPERSON) address = Address() - address.setStartDate(edit_person_obj.address_start.get_text()) - address.setStopDate(edit_person_obj.address_stop.get_text()) + address.setDate(edit_person_obj.address_start.get_text()) address.setStreet(edit_person_obj.address_street.get_text()) address.setCity(edit_person_obj.address_city.get_text()) address.setState(edit_person_obj.address_state.get_text()) @@ -1018,7 +1014,7 @@ def on_apply_person_clicked(obj): if error == 1: msg = _("Changing the gender caused problems with marriage information.") - msg2 = _("Please check the person's marriage relationships.") + msg2 = _("Please check the person's marriages.") GnomeErrorDialog(msg + msg2) text = edit_person_obj.notes_field.get_chars(0,-1) diff --git a/src/OpenOfficeDoc.py b/src/OpenOfficeDoc.py index f6acae7a6..d13835d04 100644 --- a/src/OpenOfficeDoc.py +++ b/src/OpenOfficeDoc.py @@ -26,6 +26,12 @@ from TextDoc import * from latin_utf8 import latin_to_utf8 import const +try: + import PIL + no_pil = 0 +except: + no_pil = 1 + try: from codecs import * except: @@ -418,8 +424,13 @@ class OpenOfficeDoc(TextDoc): height = file_tuple[2] base = os.path.basename(file) image_name = self.tempdir + os.sep + "Pictures" + os.sep + base - cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,image_name) - os.system(cmd) + if no_pil: + cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,image_name) + os.system(cmd) + else: + im = PIL.Image.open(file) + im.thumbnail((width,height)) + im.save(name,"JPEG") def _write_manifest(self): file = self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml"