- Compress images based on a set of rules
- Flexible rules for compression:
- By model where images are uploaded
- By mimetype; a regular expression that allows to filter what type of images to compress
- By size; it allows to compress images having a bigger size than the configured size
- Compress attachments newer or older than specific dates
Configuration: Setup a compression rule
- Select the models where image attachments to be compressed.
- Set the source format and destination format (NOTE: The source format should be a regular expression of mimetypes e.g. images/.*bmp.*).
- Set the optional minimum size of attachment.
- Set the optional newer than/older than days to compress.
- Set the quality of the compressed image (value between 0 and 100 where the larger the value, the higher the compression but the lower the quality)
In Odoo, storage is done by content. Thus, if the same image was uploaded twice, it will be saved on the disk once.
Thus, there is an option to match all similar images, compress them and delete the uncompressed images.
To activate this feature, check the "Replace All"
- If you want the scheduled action to run this compression rule daily, keep it active.
- Upon installing the module, a daily scheduled action "Run attachments compression rules" is added automatically
Add some image attachments in the models.
In the following example, I selected the employee model in my compression rule. So, I am adding a BMP image there.
Run the compression rule:
Go to the corresponding compression rule and run it. The Images satisfying these rules should be compressed.
The system will show a pop up with the details of the compression:
compressed images and total size reduction
Go back to the model where the image was uploaded and verify the results.
Download the image and check the size reduction.
Notice that upon running a compression rule or when the scheduled action runs them,
the size of the filestore is reduced if Replace All was checked