[Erp5-report] r32868 fabien - /erp5/trunk/products/ERP5Form/ImageField.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Feb 19 17:07:03 CET 2010
Author: fabien
Date: Fri Feb 19 17:07:00 2010
New Revision: 32868
URL: http://svn.erp5.org?rev=32868&view=rev
Log:
use the real width and height of the image data
Modified:
erp5/trunk/products/ERP5Form/ImageField.py
Modified: erp5/trunk/products/ERP5Form/ImageField.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ImageField.py?rev=32868&r1=32867&r2=32868&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ImageField.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/ImageField.py [utf8] Fri Feb 19 17:07:00 2010
@@ -30,6 +30,7 @@
from Products.Formulator import Widget, Validator
from Products.Formulator.Field import ZMIField
from Products.Formulator.DummyField import fields
+from OFS.Image import Image as OFSImage
from lxml.etree import Element
from Acquisition import aq_base
from lxml import etree
@@ -135,6 +136,12 @@
# is displayed in the form as a thumbnail, it will be added in the odg
# document as thumbnail size/quality
content_type, image_data = image_object.convert(**image_parameter_dict)
+ if isinstance(image_data, str):
+ image = OFSImage('', '', image_data)
+ else:
+ image = image_data
+ width = image.width
+ height = image.height
if image_data is None:
return draw_frame_node
@@ -154,8 +161,11 @@
# set the size of the image
if display is not None:
- width, height = image_object.getSizeFromImageDisplay(display)
- width, height = image_object._getAspectRatioSize(width, height)
+ # if the image width and height are not on defined, use current
+ # width and height
+ if (image_object.getWidth(), image_object.getHeight()) not in \
+ ((-1, -1), (0,0)):
+ width, height = image_object._getAspectRatioSize(width, height)
if draw_frame_node.attrib.get('{%s}width' % SVG_URI, {}) != {} and \
draw_frame_node.attrib.get('{%s}height' % SVG_URI, {}) != {}:
# if a size already exist from attr_dict, try to resize the image to
More information about the Erp5-report
mailing list