0004905: Bug in ODF output format that ONLY crops the first image correctly (Patch from Adam Stein)

svn: r17483
This commit is contained in:
Brian Matherly 2011-05-13 03:58:41 +00:00
parent a440d1c307
commit b49ca7608e
2 changed files with 1 additions and 210 deletions

View File

@ -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):

View File

@ -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())