Use the python image library to do image conversions if it is present
svn: r51
This commit is contained in:
parent
6a375487db
commit
3c6eee59c8
@ -26,6 +26,13 @@ from latin_utf8 import latin_to_utf8
|
|||||||
import const
|
import const
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
try:
|
||||||
|
import PIL
|
||||||
|
no_pil = 0
|
||||||
|
except:
|
||||||
|
no_pil = 1
|
||||||
|
|
||||||
|
|
||||||
class AbiWordDoc(TextDoc):
|
class AbiWordDoc(TextDoc):
|
||||||
|
|
||||||
def __init__(self,type,orientation):
|
def __init__(self,type,orientation):
|
||||||
@ -70,8 +77,15 @@ class AbiWordDoc(TextDoc):
|
|||||||
height = file_tuple[2]
|
height = file_tuple[2]
|
||||||
base = "/tmp/%s.png" % os.path.basename(file)
|
base = "/tmp/%s.png" % os.path.basename(file)
|
||||||
tag = string.replace(base,'.','_')
|
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('<d name="')
|
self.f.write('<d name="')
|
||||||
self.f.write(tag)
|
self.f.write(tag)
|
||||||
self.f.write('" mime-type="image/png" base64="yes">\n')
|
self.f.write('" mime-type="image/png" base64="yes">\n')
|
||||||
|
@ -324,8 +324,7 @@ class EditPerson:
|
|||||||
for address in self.person.getAddressList():
|
for address in self.person.getAddressList():
|
||||||
location = address.getCity() + " " + address.getState() + " " + \
|
location = address.getCity() + " " + address.getState() + " " + \
|
||||||
address.getCountry()
|
address.getCountry()
|
||||||
self.address_list.append([address.getStartDate(),\
|
self.address_list.append([address.getDate(),location])
|
||||||
address.getStopDate(),location])
|
|
||||||
self.address_list.set_row_data(self.address_index,address)
|
self.address_list.set_row_data(self.address_index,address)
|
||||||
self.address_index = self.address_index + 1
|
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)
|
edit_person_obj = obj.get_data(EDITPERSON)
|
||||||
address = obj.get_row_data(row)
|
address = obj.get_row_data(row)
|
||||||
|
|
||||||
edit_person_obj.address_start.set_text(address.getStartDate())
|
edit_person_obj.address_start.set_text(address.getDate())
|
||||||
edit_person_obj.address_stop.set_text(address.getStopDate())
|
|
||||||
edit_person_obj.address_street.set_text(address.getStreet())
|
edit_person_obj.address_street.set_text(address.getStreet())
|
||||||
edit_person_obj.address_city.set_text(address.getCity())
|
edit_person_obj.address_city.set_text(address.getCity())
|
||||||
edit_person_obj.address_state.set_text(address.getState())
|
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)
|
edit_person_obj = obj.get_data(EDITPERSON)
|
||||||
|
|
||||||
address = obj.get_row_data(row)
|
address = obj.get_row_data(row)
|
||||||
address.setStartDate(edit_person_obj.address_start.get_text())
|
address.setDate(edit_person_obj.address_start.get_text())
|
||||||
address.setStopDate(edit_person_obj.address_stop.get_text())
|
|
||||||
address.setStreet(edit_person_obj.address_street.get_text())
|
address.setStreet(edit_person_obj.address_street.get_text())
|
||||||
address.setCity(edit_person_obj.address_city.get_text())
|
address.setCity(edit_person_obj.address_city.get_text())
|
||||||
address.setState(edit_person_obj.address_state.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)
|
edit_person_obj = obj.get_data(EDITPERSON)
|
||||||
|
|
||||||
address = Address()
|
address = Address()
|
||||||
address.setStartDate(edit_person_obj.address_start.get_text())
|
address.setDate(edit_person_obj.address_start.get_text())
|
||||||
address.setStopDate(edit_person_obj.address_stop.get_text())
|
|
||||||
address.setStreet(edit_person_obj.address_street.get_text())
|
address.setStreet(edit_person_obj.address_street.get_text())
|
||||||
address.setCity(edit_person_obj.address_city.get_text())
|
address.setCity(edit_person_obj.address_city.get_text())
|
||||||
address.setState(edit_person_obj.address_state.get_text())
|
address.setState(edit_person_obj.address_state.get_text())
|
||||||
@ -1018,7 +1014,7 @@ def on_apply_person_clicked(obj):
|
|||||||
|
|
||||||
if error == 1:
|
if error == 1:
|
||||||
msg = _("Changing the gender caused problems with marriage information.")
|
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)
|
GnomeErrorDialog(msg + msg2)
|
||||||
|
|
||||||
text = edit_person_obj.notes_field.get_chars(0,-1)
|
text = edit_person_obj.notes_field.get_chars(0,-1)
|
||||||
|
@ -26,6 +26,12 @@ from TextDoc import *
|
|||||||
from latin_utf8 import latin_to_utf8
|
from latin_utf8 import latin_to_utf8
|
||||||
import const
|
import const
|
||||||
|
|
||||||
|
try:
|
||||||
|
import PIL
|
||||||
|
no_pil = 0
|
||||||
|
except:
|
||||||
|
no_pil = 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from codecs import *
|
from codecs import *
|
||||||
except:
|
except:
|
||||||
@ -418,8 +424,13 @@ class OpenOfficeDoc(TextDoc):
|
|||||||
height = file_tuple[2]
|
height = file_tuple[2]
|
||||||
base = os.path.basename(file)
|
base = os.path.basename(file)
|
||||||
image_name = self.tempdir + os.sep + "Pictures" + os.sep + base
|
image_name = self.tempdir + os.sep + "Pictures" + os.sep + base
|
||||||
cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,image_name)
|
if no_pil:
|
||||||
os.system(cmd)
|
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):
|
def _write_manifest(self):
|
||||||
file = self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml"
|
file = self.tempdir + os.sep + "META-INF" + os.sep + "manifest.xml"
|
||||||
|
Loading…
Reference in New Issue
Block a user