From b49ca7608e6f3f86ddf336807a28227aa74caaed Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Fri, 13 May 2011 03:58:41 +0000 Subject: [PATCH] 0004905: Bug in ODF output format that ONLY crops the first image correctly (Patch from Adam Stein) svn: r17483 --- src/ImgManip.py | 210 +---------------------------------- src/plugins/docgen/ODFDoc.py | 1 - 2 files changed, 1 insertion(+), 210 deletions(-) diff --git a/src/ImgManip.py b/src/ImgManip.py index d655e80f2..00e19486e 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -106,114 +106,6 @@ def image_dpi(source): return dpi -#------------------------------------------------------------------------- -# -# image_dpi -# -#------------------------------------------------------------------------- -def image_dpi(source): - """ - Return the dpi found in the image header. None is returned if no dpi attribute - is available. - - :param source: source image file, in any format that PIL recognizes - :type source: unicode - :rtype: int - :returns: the DPI setting in the image header - """ - try: - import PIL.Image - except ImportError: - import sys - print >> sys.stderr, _("WARNING: PIL module not loaded. " - "Image cropping in report files will not be available.") - - dpi = None - else: - try: - img = PIL.Image.open(source) - except IOError: - dpi = None - else: - try: - dpi = img.info["dpi"] - except AttributeError, KeyError: - dpi = None - - return dpi - -#------------------------------------------------------------------------- -# -# image_dpi -# -#------------------------------------------------------------------------- -def image_dpi(source): - """ - Return the dpi found in the image header. None is returned if no dpi attribute - is available. - - :param source: source image file, in any format that PIL recognizes - :type source: unicode - :rtype: int - :returns: the DPI setting in the image header - """ - try: - import PIL.Image - except ImportError: - import sys - print >> sys.stderr, _("WARNING: PIL module not loaded. " - "Image cropping in report files will not be available.") - - dpi = None - else: - try: - img = PIL.Image.open(source) - except IOError: - dpi = None - else: - try: - dpi = img.info["dpi"] - except AttributeError, KeyError: - dpi = None - - return dpi - -#------------------------------------------------------------------------- -# -# image_dpi -# -#------------------------------------------------------------------------- -def image_dpi(source): - """ - Return the dpi found in the image header. None is returned if no dpi attribute - is available. - - :param source: source image file, in any format that PIL recognizes - :type source: unicode - :rtype: int - :returns: the DPI setting in the image header - """ - try: - import PIL.Image - except ImportError: - import sys - print >> sys.stderr, _("WARNING: PIL module not loaded. " - "Image cropping in report files will not be available.") - - dpi = None - else: - try: - img = PIL.Image.open(source) - except IOError: - dpi = None - else: - try: - dpi = img.info["dpi"] - except AttributeError, KeyError: - dpi = None - - return dpi - #------------------------------------------------------------------------- # # image_size @@ -241,107 +133,7 @@ def image_size(source): #------------------------------------------------------------------------- # -# image_cropped_size -# -#------------------------------------------------------------------------- -def image_actual_size(x_cm, y_cm, x, y): - """ - Calculate what the actual width & height of the image should be. - - :param x_cm: width in centimeters - :type source: int - :param y_cm: height in centimeters - :type source: int - :param x: desired width in pixels - :type source: int - :param y: desired height in pixels - :type source: int - :rtype: tuple(int, int) - :returns: a tuple consisting of the width and height in centimeters - """ - - print "[Actual Size] CM = [", x_cm, ",", y_cm, "], Desired = [", x, ",", y, "]" - ratio = float(x_cm)*float(y)/(float(y_cm)*float(x)) - - if ratio < 1: - act_width = x_cm - act_height = y_cm*ratio - else: - act_height = y_cm - act_width = x_cm/ratio - - print "[Actual Size] Size = [", act_width, ",", act_height, "]" - return (act_width, act_height) - -#------------------------------------------------------------------------- -# -# image_cropped_size -# -#------------------------------------------------------------------------- -def image_actual_size(x_cm, y_cm, x, y): - """ - Calculate what the actual width & height of the image should be. - - :param x_cm: width in centimeters - :type source: int - :param y_cm: height in centimeters - :type source: int - :param x: desired width in pixels - :type source: int - :param y: desired height in pixels - :type source: int - :rtype: tuple(int, int) - :returns: a tuple consisting of the width and height in centimeters - """ - - print "[Actual Size] CM = [", x_cm, ",", y_cm, "], Desired = [", x, ",", y, "]" - ratio = float(x_cm)*float(y)/(float(y_cm)*float(x)) - - if ratio < 1: - act_width = x_cm - act_height = y_cm*ratio - else: - act_height = y_cm - act_width = x_cm/ratio - - print "[Actual Size] Size = [", act_width, ",", act_height, "]" - return (act_width, act_height) - -#------------------------------------------------------------------------- -# -# image_cropped_size -# -#------------------------------------------------------------------------- -def image_actual_size(x_cm, y_cm, x, y): - """ - Calculate what the actual width & height of the image should be. - - :param x_cm: width in centimeters - :type source: int - :param y_cm: height in centimeters - :type source: int - :param x: desired width in pixels - :type source: int - :param y: desired height in pixels - :type source: int - :rtype: tuple(int, int) - :returns: a tuple consisting of the width and height in centimeters - """ - - ratio = float(x_cm)*float(y)/(float(y_cm)*float(x)) - - if ratio < 1: - act_width = x_cm - act_height = y_cm*ratio - else: - act_height = y_cm - act_width = x_cm/ratio - - return (act_width, act_height) - -#------------------------------------------------------------------------- -# -# image_cropped_size +# image_actual_size # #------------------------------------------------------------------------- def image_actual_size(x_cm, y_cm, x, y): diff --git a/src/plugins/docgen/ODFDoc.py b/src/plugins/docgen/ODFDoc.py index 9e1fa7453..d7bcb9db7 100644 --- a/src/plugins/docgen/ODFDoc.py +++ b/src/plugins/docgen/ODFDoc.py @@ -790,7 +790,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): self.StyleList_notes = self.uniq(self.StyleList_notes) self.add_styled_notes_fonts() self.add_styled_notes_styles() - self.StyleList_photos = self.uniq(self.StyleList_photos) self.add_styled_photo_styles() self.cntntx.write(self.cntnt1.getvalue()) self.cntntx.write(self.cntnt2.getvalue())