Commit 30dc5ee0 authored by Jérome Perrin's avatar Jérome Perrin

prevent ZeroDivisionError on empty images


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19841 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8b6ca55c
......@@ -365,13 +365,18 @@ xmlns:config="http://openoffice.org/2001/config" office:version="1.0">
w, h, maxwidth, maxheight = getLengthInfos(options_dict, ('width', 'height', 'maxwidth', 'maxheight'))
aspect_ratio = 1
try: # try image properties
aspect_ratio = float(picture.width) / float(picture.height)
except (TypeError, ZeroDivisionError):
try: # try ERP5.Document.Image API
aspect_ratio = float(picture.getWidth()) / float(picture.getHeight())
height = float(picture.getHeight())
if height:
aspect_ratio = float(picture.getWidth()) / height
except AttributeError: # fallback to Photo API
aspect_ratio = float(picture.width()) / float(picture.height())
height = float(picture.height())
if height:
aspect_ratio = float(picture.width()) / height
# fix a default value and correct the aspect
if h is None:
if w is None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment