Protection from scale error

svn: r15165
This commit is contained in:
Doug Blank 2010-04-16 15:38:32 +00:00
parent 02d78e66ef
commit 9a8626a668

View File

@ -2690,10 +2690,14 @@ class MediaPage(BasePage):
(width, height) = ImgManip.image_size(orig_image_path)
max_width = self.report.options['maxinitialimagewidth']
max_height = self.report.options['maxinitialimageheight']
scale_w = (float(max_width)/width) or 1 # the 'or 1' is so that
# a max of zero is ignored
if width != 0 and height != 0:
scale_w = (float(max_width)/width) or 1 # the 'or 1' is so that
# a max of zero is ignored
scale_h = (float(max_height)/height) or 1
scale_h = (float(max_height)/height) or 1
else:
scale_w = 1.0
scale_h = 1.0
scale = min(scale_w, scale_h, 1.0)
new_width = int(width*scale)
new_height = int(height*scale)