Help

2

How to resize image in odoo new api (Odoo9)?

Avatar
Sebin Siby

Hi,


I want to resize the uploaded image in my application and save it to the database, how to achieve this in odoo9?

Avatar
Discard
2 Answers
0
Avatar
kirubanidhi
Best Answer

Hai,

In odoo 9 we Specify these header file

from openerp.tools import DEFAULT_SERVER_DATE_FORMAT,image_colorize, image_resize_image_big

Py file:

stud_image = fields.Binary('Photo', default=lambda self:\

self._get_default_image())

@api.model

def _get_default_image(self, colorize=False):

image = image_colorize(open(openerp.modules.get_module_resource('base',

'static/src/img', 'avatar.png')).read())

return image_resize_image_big(image.encode('base64'))

Avatar
Discard
0
Best Answer

You can maybe follow the res_partner code:

http://gitlab.opengest.solutions/opengest/odoo/blob/9.0/openerp/addons/base/res/res_partner.py#L257

image_medium = openerp.fields.Binary("Medium-sized image", attachment=True,

help="Medium-sized image of this contact. It is automatically "\

"resized as a 128x128px image, with aspect ratio preserved. "\

"Use this field in form views or some kanban views.")

http://gitlab.opengest.solutions/opengest/odoo/blob/9.0/openerp/addons/base/res/res_partner.py#L290

1 Comment
Avatar
Discard
Avatar
OpenGest.Solutions
-