Skip to content
Snippets Groups Projects
Commit 6bb6944e authored by Xavier Morel's avatar Xavier Morel
Browse files

[FIX] P3: resizing of image *fields*

Fields sent from the client are pretty much always *text*. This can be
problematic for image fields sent as base64 *text* as in Python 3 the
base64 routines only work between bytes.

Alter the core field-resizing function (image_get_resized_images) such
that it ensures text base64 sources are encoded back to bytes before
being forwarded to the main resizing routines (which I don't think
should deal with *that* issue).

Fixes #18985: error when trying to update a company's logo
parent 9dff6516
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ from PIL import ImageEnhance
from random import randrange
# Preload PIL with the minimal subset of image formats we need
from odoo.tools import pycompat
Image.preinit()
Image._initialized = 2
......@@ -253,6 +255,8 @@ def image_get_resized_images(base64_source, return_big=False, return_medium=True
previous parameters.
"""
return_dict = dict()
if isinstance(base64_source, pycompat.text_type):
base64_source = base64_source.encode('ascii')
if return_big:
return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big)
if return_medium:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment