Purpose of this commit is to finally stop adding extra padding to
website logo. Indeed not giving square logos lead to padding added
to images, leading to not so beautiful logo that makes people sad.
Before this commit
* partner's image was resized to square 1024x1024. Extra padding was added
if user provided rectangle image;
* due to this website logo resized to square when rectangle logo provided;
After this commit,
* sizes dict can be passed in image resizer of tools;
* e.g. tools.image_resize_images(vals, sizes={'image': (512, 512),
'image_small': (128, 128)})
* image field in partner will resize with max width 1024 and height based
on given image ratio (still image_medium, image_small will be default
square images);
* now website logo will respect actual aspect ratio
This commit is related to task ID 31994 . Future commits should probably
clean all that mess, but at least it seems we have something that works.
Fixes#20046
Simply reverting e5ef1c5917 looks to
work *but* since I didn't note the repro case for the issue and don't
remember what it was it may re-introduce previous breakage. Instead,
ensure all "sizes" for the image are reset if any of the sizes is
present *and* Falsy by adding a final case to the conditional.
If any of the image fields is present and non-falsy one of the
previous branches will be taken, so we can just check that any of the
image fields is present at all (this implies it's falsy).
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
Purpose
=======
It makes no sense to crop an image from a ration. We don't say "I don't know my image size, but divide it by 2"
Specification
=============
Pass a maximum size argument instead of a thumbnail ratio
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
codecs (via #encode) so replace all calls to str.encode('base64'),
also b64encode is a bytes->bytes conversion so attempt to properly
handle that
issue #8530