Skip to content
Permalink
Browse files

fix crop, need to write better test

  • Loading branch information...
seb-odoo committed Mar 25, 2019
1 parent 1e06c7e commit d6051b04bc74830230d92ebb5c8c61dc176c2262
Showing with 7 additions and 1 deletion.
  1. +7 −1 odoo/tools/image.py
@@ -115,7 +115,13 @@ def image_process(base64_source, size=(0, 0), verify_resolution=False, quality=8
asked_height = size[1] or (h * size[0]) // w

if crop:
new_w, new_h = w, h
# We want to keep as much of the image as possible -> at least one
# of the 2 crop dimensions always has to be the same value as the
# original image. The target size will be met with a resize after.
if w / asked_width > h / asked_height:
new_w, new_h = w, (asked_height * w) // asked_width
else:
new_w, new_h = (asked_width * h) // asked_height, h

if new_w > w:
new_w, new_h = w, (new_h * w) // new_w

0 comments on commit d6051b0

Please sign in to comment.
You can’t perform that action at this time.