Welcome!

This community is for professionals and enthusiasts of our products and services.Share and discuss the best content and new marketing ideas,build your professional profile and become a better marketer together.

Register
1

How can I automatically resize an uploaded image?

By
Diogo Duarte
on 11/4/15, 10:38 PM816 views

How can I automatically resize an uploaded image?


1
Diogo Duarte
On11/4/15, 10:40 PM

You can add a computed field like

image = fields.Binary('Image', compute='_resize_image', store=True, attachment=True)

and use the following methods (which are defined on tools) to automatically resize an image: "image_resize_image_big" (1024x1024); "image_resize_image_medium" (128x128); "image_resize_image_small" (64x64).

You can define _resize_image method like:

self.image = tools.image_resize_image_medium(self.image)

or you can also change the default width and height of the resized image by providing the default size value parameter on those methods like:

self.image = tools.image_resize_image_medium(self.image, size=(256, 256))

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, justuse the commenting tool. Please remember that you can alwaysrevise your answers - no need to answer the same question twice. Also, pleasedon't forget to vote - it really helps to select the best questions and answers!

Keep Informed

About This Community

This community is for professionals and enthusiasts of our products and services.Share and discuss the best content and new marketing ideas,build your professional profile and become a better marketer together.

Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/4/15, 10:38 PM
Seen: 816 times
Last updated: 11/5/15, 1:21 AM