Skip to Content
Menu
This question has been flagged
4079 Views

Hello,

I am trying to put some picture on report.

The objectif is that users choose a picture ( size and shape what they wants) and when they print the report, the picture is inside the report.

I tried with the image_resize_image.

I have a problem: Or the picture is to big, or when I use the image_resize, it is cut me part of the picture ( I use picture that are not square).

Someone has another idea?

 

This is my code:

 

from openerp.tools import image_resize_image

        'image':fields.binary("Picture",
            help="This field holds the image used as avatar for this contact, limited to 1024x1024px"),

        'image_medium': fields.function(_get_image, fnct_inv=_set_image,
            string="Medium-sized image", type="binary", multi="_get_image",
            store={
                'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
            },
            help="Medium-sized image of the product. It is automatically "\
                 "resized as a 128x128px image, with aspect ratio preserved, "\
                 "only when the image exceeds one of those sizes. Use this field in form views or some kanban views."),

        'image_small': fields.function(_get_image, fnct_inv=_set_image,
            string="Small-sized image", type="binary", multi="_get_image",
            store={
                'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10),
            },
            help="Small-sized image of the product. It is automatically "\
                 "resized as a 64x64px image, with aspect ratio preserved. "\
                 "Use this field anywhere a small image is required."),

 

Thank you a lot,

 

Selverine

Avatar
Discard
Author

Maybe it exist another function like image_resize_image but that resize and keep the shape of the picture?