odoo_xmlrpc_twisted.functions.save_picture

Module saves the picture of an object in Odoo.

Functions

pad_if_needed(img, target_aspect_ratio[, ...])

Adds padding only if the image's aspect ratio does not match the target.

save_picture(product_id, perspective_or_image)

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

odoo_xmlrpc_twisted.functions.save_picture.save_picture(product_id, perspective_or_image, image=None)[source]

Function saves the picture under the product_template_id of the product. The image will be stored with the image size from ‘custom_image_size’.