odoo_xmlrpc_twisted.functions.save_picture¶
Module saves the picture of an object in Odoo.
Functions
|
Adds padding only if the image's aspect ratio does not match the target. |
|
Function saves the picture under the product_template_id of the product. |
- odoo_xmlrpc_twisted.functions.save_picture.pad_if_needed(img, target_aspect_ratio, padding_color=(0, 0, 0, 0))[source]¶
Adds padding only if the image’s aspect ratio does not match the target. Keeps the original image unchanged and centers it on a new canvas if needed.
- Parameters:
img – PIL.Image – input image (any mode)
target_aspect_ratio – float – desired aspect ratio (width / height)
padding_color – tuple or int – background color (must match img.mode)
- Returns:
PIL.Image – either the original image or a padded one