Hi,
I want to resize the uploaded image in my application and save it to the database, how to achieve this in odoo9?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hi,
I want to resize the uploaded image in my application and save it to the database, how to achieve this in odoo9?
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'))
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
The function resizing the image:
http://gitlab.opengest.solutions/opengest/odoo/blob/9.0/openerp/tools/image.py#L131