odoo/odoo#96307

Created by Nicolas Lempereur (nle)
label
odoo-dev:14.0-base-opw-2897291-nle
head
bbdfdd21f0fd158091f58dbb7bc18e3514b43ad0
target
14.0
merged
2 years ago by Nicolas Lempereur (nle)
forward-ports

[FIX] base: fix autoresize and exclude gif

Odoo may resize attachment image with side larger than 1920 pixels.

But for animated gifs, this resizement seems to in general increase size
file which is not what we want (in some case making it grow from 3MB to
60 MB).

So with this change, we only resize and optimize images that are not
gifs.

Reasoning: pillow doesn't seem to resize GIF (and seems to only increase
their size, especially animated GIF, because each frame is not
optimized) so we should just not touch them.

Note:

- currently tiff were not resized (because of a mimetype typo)
- currently image dimensions were not resized (from our test, resizing
on the dimension does not change the size much, quality is most
important).

both of these issue have been solved in this commit.

opw-[2897291](https://www.odoo.com/web#id=2897291&view_type=form&model=project.task)

Note: In the ticket case, a 4MB gif would grow to 60 MB. Here is an example of a 300 KB gif that is getting saved as 3 MB:

![bignyan](https://user-images.githubusercontent.com/9977887/179728314-8255e120-dedd-4457-93a7-c4d025ca984f.gif)