diff --git a/product/ERP5/Document/Image.py b/product/ERP5/Document/Image.py index 73b6677458d84fef1b5410b5268a8ad609300f19..6d6ab0a642e4ce09cd8accfb49263af104323066 100644 --- a/product/ERP5/Document/Image.py +++ b/product/ERP5/Document/Image.py @@ -489,6 +489,12 @@ class Image(File, OFSImage): return (height, width) return None + def _setFile(self, *args, **kw): + """set the file content and reset image information. + """ + File._setFile(self, *args, **kw) + self._update_image_info() + # # FTP/WebDAV support # diff --git a/product/ERP5/tests/testERP5Base.py b/product/ERP5/tests/testERP5Base.py index ace729a409398f704dcf2a5da3d01f202f479a13..da5dd2c559abca291c934f35c5aa905fa25b2e1b 100644 --- a/product/ERP5/tests/testERP5Base.py +++ b/product/ERP5/tests/testERP5Base.py @@ -1201,6 +1201,15 @@ class TestERP5Base(ERP5TypeTestCase): # magic self.assertEquals('\xff', image_data[0]) self.assertEquals('\xd8', image_data[1]) + + def test_ImageSize(self): + image = self.portal.newContent(portal_type='Image', id='test_image') + image.edit(file=self.makeImageFileUpload('erp5_logo.png')) + self.assertEquals(320, image.getWidth()) + self.assertEquals(250, image.getHeight()) + image.edit(file=self.makeImageFileUpload('erp5_logo_small.png')) + self.assertEquals(160, image.getWidth()) + self.assertEquals(125, image.getHeight()) def test_Person_getCareerStartDate(self): # Person_getCareerStartDate scripts returns the date when an employee diff --git a/product/ERP5/tests/test_data/images/erp5_logo_small.png b/product/ERP5/tests/test_data/images/erp5_logo_small.png new file mode 100644 index 0000000000000000000000000000000000000000..6578c361dcffba3d0ae3fa06cb45ab9100292879 Binary files /dev/null and b/product/ERP5/tests/test_data/images/erp5_logo_small.png differ