From 50661365f29e7058de7af507fefb0ae8818d94a1 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 7 Feb 2002 00:51:07 +0000 Subject: [PATCH] Better image handing/conversion svn: r759 --- gramps/src/ImgManip.py | 66 +++++++++++++++++++++++------- gramps/src/docgen/OpenOfficeDoc.py | 4 +- gramps/src/docgen/PdfDoc.py | 1 + 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/gramps/src/ImgManip.py b/gramps/src/ImgManip.py index 3272a4c63..fedc7d691 100644 --- a/gramps/src/ImgManip.py +++ b/gramps/src/ImgManip.py @@ -55,20 +55,6 @@ class ImgManip: im = im.convert("RGB") im.save(dest,"JPEG") - def png_thumbnail(self,dest,width,height): - if no_pil: - w = int(width) - h = int(height) - cmd = "%s -geometry %dx%d '%s' 'png:%s'" % (const.convert,w,h,self.source,dest) - os.system(cmd) - else: - im = PIL.Image.open(self.source) - im.thumbnail((width,height)) - if im.mode != 'RGB': - im.draft('RGB',im.size) - im = im.convert("RGB") - im.save(dest,"PNG") - def size(self): if no_pil: img = GdkImlib.Image(self.source) @@ -149,6 +135,33 @@ class ImgManip: g.close() return buf + def eps_thumbnail(self,dest,width,height): + if no_pil: + w = int(width) + h = int(height) + cmd = "%s -geometry %dx%d '%s' 'eps:%s'" % (const.convert,w,h,self.source,dest) + os.system(cmd) + else: + im = PIL.Image.open(self.source) + im.thumbnail((width,height)) + if im.mode != 'RGB': + im.draft('RGB',im.size) + im = im.convert("RGB") + im.save(dest,"eps") + + def eps_convert(self,dest): + if no_pil: + cmd = "%s -geometry '%s' 'eps:%s'" % (const.convert,self.source,dest) + os.system(cmd) + else: + im = PIL.Image.open(self.source) + im.thumbnail((width,height)) + if im.mode != 'RGB': + im.draft('RGB',im.size) + im = im.convert("RGB") + im.save(dest,"eps") + + def png_data(self): if no_pil: cmd = "%s -geometry '%s' 'jpg:-'" % (const.convert,self.source) @@ -180,4 +193,29 @@ class ImgManip: im = im.convert("RGB") return im.tostring("png","RGB") + def png_thumbnail(self,dest,width,height): + if no_pil: + w = int(width) + h = int(height) + cmd = "%s -geometry %dx%d '%s' 'png:%s'" % (const.convert,w,h,self.source,dest) + os.system(cmd) + else: + im = PIL.Image.open(self.source) + im.thumbnail((width,height)) + if im.mode != 'RGB': + im.draft('RGB',im.size) + im = im.convert("RGB") + im.save(dest,"PNG") + + def png_convert(self,dest) + if no_pil: + cmd = "%s '%s' 'png:%s'" % (const.convert,self.source,dest) + os.system(cmd) + else: + im = PIL.Image.open(self.source) + if im.mode != 'RGB': + im.draft('RGB',im.size) + im = im.convert("RGB") + im.save(dest,"PNG") + diff --git a/gramps/src/docgen/OpenOfficeDoc.py b/gramps/src/docgen/OpenOfficeDoc.py index 4228d314b..9fe590e05 100644 --- a/gramps/src/docgen/OpenOfficeDoc.py +++ b/gramps/src/docgen/OpenOfficeDoc.py @@ -251,8 +251,8 @@ class OpenOfficeDoc(TextDoc): self.f.write('draw:name="') self.f.write(tag) self.f.write('" text:anchor-type="paragraph" ') - self.f.write('svg:width="%.3fcm" ' % x_cm*scale) - self.f.write('svg:height="%.3fcm" ' % y_cm*scale) + self.f.write('svg:width="%.3fcm" ' % (x_cm*scale)) + self.f.write('svg:height="%.3fcm" ' % (y_cm*scale)) self.f.write('draw:z-index="0" ') self.f.write('xlink:href="#Pictures/') self.f.write(base) diff --git a/gramps/src/docgen/PdfDoc.py b/gramps/src/docgen/PdfDoc.py index 3a034c009..e046ca158 100644 --- a/gramps/src/docgen/PdfDoc.py +++ b/gramps/src/docgen/PdfDoc.py @@ -25,6 +25,7 @@ #------------------------------------------------------------------------ from TextDoc import * import Plugins +import ImgManip import intl _ = intl.gettext