Fix image handling problems for reports.

svn: r6269
This commit is contained in:
Brian Matherly 2006-04-05 04:41:56 +00:00
parent 050c4e3f08
commit ed211a6aab
4 changed files with 25 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2006-04-04 Brian Matherly <pez4brian@users.sourceforge.net>
* src/_ImgManip.py: open images as binary
* src/docgen/ODFDoc.py: open images as binary, fix image embedding
* src/docgen/OpenOfficeDoc.py: open images as binary
2006-04-04 Don Allingham <don@gramps-project.org>
* src/RelLib/_LdsOrd.py: lds status changes
* src/Editors/_EditLdsOrd.py: lds status changes

View File

@ -76,20 +76,26 @@ class ImgManip:
def fmt_data(self, cnv):
fd, dest = tempfile.mkstemp()
self.img.save(dest,cnv)
fh = open(dest)
fh = open(dest,mode='rb')
data = fh.read()
fh.close()
os.unlink(dest)
try:
os.unlink(dest)
except:
pass
return data
def fmt_scale_data(self, x, y, cnv):
fd, dest = tempfile.mkstemp()
scaled = self.img.scale_simple(x, y, gtk.gdk.INTERP_BILINEAR)
self.img.save(dest,cnv)
fh = open(dest)
scaled.save(dest,cnv)
fh = open(dest,mode='rb')
data = fh.read()
fh.close()
os.unlink(dest)
try:
os.unlink(dest)
except:
pass
return data
def jpg_thumbnail(self, dest, width, height):

View File

@ -450,23 +450,24 @@ class ODFDoc(BaseDoc.BaseDoc):
if self.new_cell:
self.cntnt.write('<text:p>')
if pos == "left":
self.cntnt.write('<draw:image draw:style-name="Left" ')
self.cntnt.write('<draw:frame draw:style-name="Left" ')
elif pos == "right":
self.cntnt.write('<draw:image draw:style-name="Right" ')
self.cntnt.write('<draw:frame draw:style-name="Right" ')
elif pos == "single":
self.cntnt.write('<draw:image draw:style-name="Single" ')
self.cntnt.write('<draw:frame draw:style-name="Single" ')
else:
self.cntnt.write('<draw:image draw:style-name="Row" ')
self.cntnt.write('<draw:frame draw:style-name="Row" ')
self.cntnt.write('draw:name="%s" ' % tag)
self.cntnt.write('text:anchor-type="paragraph" ')
self.cntnt.write('svg:width="%.2fcm" ' % act_width)
self.cntnt.write('svg:height="%.2fcm" ' % act_height)
self.cntnt.write('draw:z-index="0" ')
self.cntnt.write('xlink:href="#Pictures/')
self.cntnt.write('draw:z-index="0" >')
self.cntnt.write('<draw:image xlink:href="Pictures/')
self.cntnt.write(base)
self.cntnt.write('" xlink:type="simple" xlink:show="embed" ')
self.cntnt.write('xlink:actuate="onLoad"/>\n')
self.cntnt.write('</draw:frame>\n')
if self.new_cell:
self.cntnt.write('</text:p>\n')
@ -534,7 +535,7 @@ class ODFDoc(BaseDoc.BaseDoc):
for image in self.media_list:
try:
ifile = open(image[0])
ifile = open(image[0],mode='rb')
base = os.path.basename(image[0])
self._add_zip(zfile,"Pictures/%s" % base, ifile.read(),t)
ifile.close()

View File

@ -495,7 +495,7 @@ class OpenOfficeDoc(BaseDoc.BaseDoc):
for image in self.media_list:
try:
ifile = open(image[0])
ifile = open(image[0],mode='rb')
base = os.path.basename(image[0])
self._add_zip(zfile,"Pictures/%s" % base, ifile.read(),t)
ifile.close()