Image Optimizer
Lighter, cleaner eCommerce product images
Clean, light product images for the eCommerce catalog, in four jobs on the same images:
- Remove the backgroundof product photos: the product is cut out and saved on a transparent background (or a solid color), with a before / after preview so the result is checked before anything is written.
- Remove a watermarkyour catalog images carry: a semi-transparent logo blended over the photos is learned from the images themselves and removed, with the same preview.
- Remove duplicated imagesthe same picture stored twice in a product's gallery is found and deleted; a picture shared by several products is reported, never deleted.
- Recompress oversized imagesoriginals are downscaled and re-encoded (JPEG, or WebP when they have transparency), so the filestore and every shop page get lighter.
Everything runs on the Odoo server: no image is sent to an external service.
Background removal
Product photos taken on a printed mat, on a table or on a supplier's white background end up looking the same in the shop once the background is gone. Select products in a list and use Actions → Remove Image Background; on a product the action also covers its eCommerce gallery. One picture can also be cleaned from the website editor: click the product picture, then Background → Remove Background.
The original image is not kept — keeping a copy of every image would double the images in the database. The check therefore happens before anything is written, in a wizard:
- up to
bg_sync_limitimages (default 5, main and gallery images counted), the wizard shows each image before and after, on a checkerboard so leftovers are visible. Untick the ones that were not cut out well, then Apply; - a larger selection is queued for a scheduled action, which processes it in batches. Try a few images first;
- the result is saved as WebP, resized variants included.
How the product is cut out
| Method | Used for | How |
|---|---|---|
| Uniform background | photos on white or studio grey | no AI model: the background is what has the color of the image border and touches it. Dark accessories next to the product (a funnel beside a bottle) stay whole, white areas inside the product (a label) stay opaque |
| AI model | photos on a real background | a local segmentation model (rembg, ISNet by default) |
| Automatic (default) | any photo | uniform background when the image border has one color, the AI model otherwise |
After the cut-out, the specks left next to the product are removed.
Square product images without removing the background
Photos that are not square show small in the shop list, with empty bands around them. The method Frame only (keep background) keeps the background: the product is found by color, as for the uniform background, cropped and centered in a square filled with the background color, with the margin chosen in the wizard. Small pieces next to the product — a logo in a corner, a text — do not widen the square. The result is saved as JPEG and needs a photo on a plain background.
An AI model tends to keep only the main object and to lose accessories or thin parts. When it works on a plain background, its result is compared with the color cut-out: if part of the product is missing, the image is flagged and unticked in the wizard. The method and the model can be changed in the wizard and the preview refreshed.
The AI model needs the optional Python library rembg on the server (see Configuration). Without
it, photos on a plain background are still cut out by color.
Check the marketplaces and feeds the images are sent to before converting a whole catalog: some accept only JPEG or PNG, and show a transparent image on a black background. A solid white background can be chosen instead.
Watermark removal
Some catalogs carry a semi-transparent logo blended over every photo — often the shop's own logo, added once to protect the images and unwanted later (marketplaces such as eMAG refuse watermarked images). Select the products and use Actions → Remove Watermark.
The watermark is learned from the selected images, not drawn by hand: the wizard shows the
watermark it found, then each image before and after, with the same checks as for the background
(preview up to wm_sync_limit images, a queue above it, nothing written before Apply). The
cleaned image is saved opaque.
Removed today: a watermark whose blend also lowered the transparency of the image where it was drawn — some watermarking tools do this, and the image then keeps the exact mask of the logo, even over the product. From it, the module learns how strongly the logo was blended at every step and reverses the blend, instead of guessing what was under the logo. A watermark that left no trace in the transparency is reported as not found.
Only remove a watermark you have the right to remove — your own, or with the written consent of the rights holder. A supplier's or manufacturer's watermark shows who holds the rights to the photo; removing it to publish the image is not allowed without their consent (EU Directive 2001/29/EC, art. 7). The wizard says so before anything else. For supplier photos, ask the supplier for the images without watermark.
The original image is not kept. At 100% zoom faint outlines of the logo can remain on plain backgrounds, as lossy compression blurs the edges of the mask.
Duplicated product images
Finds product gallery images whose content is byte-identical, from the checksum Odoo already computes for every image: the whole catalog is scanned with one indexed query, without decoding a single image.
Two images with the same checksum are not automatically redundant:
| Situation | Meaning | Action |
|---|---|---|
| The same picture twice on one product | a genuine duplicate: the gallery shows the same thing twice | removed |
| The same picture on several products | usually a supplier feed shipping one generic photo for a whole range | never removed — each product needs its own copy |
Both happen at once, and at scale. On a real catalog of 69 761 product images (19 959 distinct contents), 17 821 — 25.5% — were redundant inside a single product, while 1 204 contents were legitimately shared across products.
Duplicated Images lists the groups side by side, so the cross-product case stays visible as a data-quality signal. Remove Duplicated Images shows exactly what will be deleted, then keeps, in each group of the same content on the same product, the image the website shows first; images carrying a video are always kept.
Only identical content is found. The same photo re-exported, resized or recompressed has a different checksum — on a product re-imported from Shopify, the same 1080×1080 shot came back at 62 KB, 76 KB and 77 KB. Removing duplicates frees catalog clutter, not much disk: Odoo stores one file per checksum, so the copies already shared a file.
Recompression
Recompresses oversized original product images and then their resized variants:
- downscaled to a maximum side of 1920 pixels;
- photos without transparency re-encoded as progressive JPEG (quality 85);
- images with real transparency kept as WebP (or optimized PNG when the server has no WebP encoder), alpha preserved;
- animated GIFs skipped;
- the result kept only when it is actually smaller.
The new image is written through the product, so Odoo regenerates the resized variants from it. Processed images are flagged and skipped on the next run; new or changed images are picked up automatically.
How much space you actually get back
Odoo stores one file per checksum, so images with identical content share one file, and recompressing one of them frees nothing while the others still point at it. Each run therefore logs two figures: the images got lighter by freed, and the disk gave back on disk. On a real deployment the first was 29 GB and the second about 4 GB — 815 000 image attachments lived in 508 000 files. Quote the on disk figure when someone asks how much space this recovers; the freed one is what every page load saves.
The filestore grows before it shrinks: the space comes back once the filestore cleanup runs, at the end of each scheduled pass.
The module works with its defaults. Everything below is tuned in Settings → Technical →
Parameters → System Parameters (developer mode), keys prefixed with deltatech_image_optimize..
Background removal
The rembg library, for photos on a real background. Photos on a plain background are cut out
by color without it. rembg is a local segmentation model on
ONNX Runtime; it is an optional dependency, not declared in the manifest, so the module installs
without it. Add it to the requirements.txt of the deployment (on odoo.sh, in the project
repository) and rebuild:
rembg[cpu]
coverage>=7.6.1
numba (a dependency of rembg) 0.61 and later needs coverage.types.Tracer, which exists only
from coverage 7.6.1; odoo.sh ships an older coverage (7.4.4), and importing rembg then fails
with module 'coverage.types' has no attribute 'Tracer'. The coverage line installs a newer
one for the server. Do not pin numba<0.61 instead: the current rembg needs numpy>=2.3, which
that numba does not accept, and pip then fails to install the requirements. Without the line the
module still works, but treats rembg as not installed and logs the error once.
The model is downloaded on first use (ISNet: 180 MB, under ~/.rembg/models or $U2NET_HOME)
and kept loaded per worker process; on CPU an image takes about one second. Only one model is kept
loaded at a time.
| Key | Default | Meaning |
|---|---|---|
bg_method |
auto | auto, uniform (by color, no AI model), rembg (always the AI model) or frame (keep the background, frame in a square) |
bg_model |
isnet-general-use | rembg model. birefnet-general is finer but about 10× slower, 970 MB, and does not fit in the memory of an odoo.sh worker |
bg_tolerance |
24 | how far (0..255 per channel) a pixel may be from the border color and still be background; raise it for noisy JPEGs or soft shadows |
bg_min_island |
1 | pieces smaller than this percent of the main object are removed; 0 = keep all |
bg_lost_warning |
5 | flag and untick an image when the AI model left out this percent of a product on a plain background |
bg_crop |
0 | 1 = frame the product in a square, 0 = keep the original canvas |
bg_margin |
5 | margin around the product, in percent, when cropping |
bg_frame_min_island |
10 | method Frame only: pieces smaller than this percent of the product (a logo in a corner) do not widen the square |
bg_color |
(empty) | empty = transparent (WebP); a color such as #FFFFFF = solid background (JPEG) |
bg_sync_limit |
5 | up to this many images (main and gallery) get a preview; more are queued |
bg_batch |
20 | images per run of the scheduled action |
Access rights. The action needs Products: Create. Writing gallery images needs Sales: Administrator or Website: Restricted Editor, as in standard Odoo.
Watermark removal
Needs the Python library numpy (installed together with rembg; otherwise add numpy to the
requirements.txt of the deployment).
| Key | Default | Meaning |
|---|---|---|
wm_sync_limit |
10 | up to this many images (main and gallery) get a preview; more are queued |
wm_learn_limit |
60 | the watermark is learned from at most this many of the selected images |
wm_batch |
20 | images per run of the scheduled action |
The watermark learned in the wizard is kept as a Learned Image Watermark record and used by the scheduled action Image Optimizer: remove product image watermark for queued images.
Recompression
| Key | Default | Meaning |
|---|---|---|
quality |
85 | JPEG quality (1..95) |
max_dim |
1920 | max side in pixels |
min_size |
102400 | only originals larger than this (bytes) |
batch |
50 | images per run |
flush_every |
20 | flush and drop the ORM cache every N images; lower it for very large images |
target_fields |
image_1920,image_variant_1920 | original fields to optimize |
webp_quality |
85 | WebP quality for transparent images |
variant_fields |
image_1024,image_512,image_256,image_128 | resized variants recompressed in place |
variant_quality |
85 | quality for re-encoding the variants |
variant_min_size |
20480 | only recompress variants larger than this (bytes) |
force_jpeg |
0 | ignore alpha, always JPEG — destructive, see below |
The scheduled action Image Optimizer: recompress oversized images runs daily and is disabled by default: review the parameters, run it manually on staging, then enable it. Its state survives module upgrades.
For a large one-time backlog, loop the batch method from the shell:
while env["ir.attachment"]._dt_image_optimize_run(limit=200)["scanned"]:
env.cr.commit()
force_jpeg is destructive — probe before enabling it
force_jpeg=1 makes the optimizer ignore the alpha channel. JPEG has no transparency, so every
transparent area is flattened to black, and the original is gone: there is no undo, the images
have to be re-imported.
Enable it only on a catalog verified to have no real transparency. "The originals are stored elsewhere" is not that verification: it covers resolution, not the alpha channel. On a real deployment, 32% of a 40-image sample of a catalog believed to be plain white shots had real alpha.
Probe first, without writing anything (_dt_image_recompress returns the bytes and the chosen
format and touches nothing):
A = env["ir.attachment"].sudo()
counts = {}
for att in A.search([("res_field", "in", ["image_1920", "image_variant_1920"]),
("mimetype", "=", "image/png"), ("file_size", ">", 51200)], limit=40):
_data, fmt = A._dt_image_recompress(att.raw, 78, 1280, 85, False)
counts[fmt] = counts.get(fmt, 0) + 1
print(counts) # any WEBP/PNG result = images that force_jpeg would destroy
Every WEBP or PNG in that count is an image with real transparency. If there is even one,
leave force_jpeg at 0: opaque images already go to JPEG on their own.
To measure the real image occupancy of the whole database (one file per checksum):
SELECT pg_size_pretty(sum(sz)) FROM (
SELECT DISTINCT ON (checksum) file_size AS sz
FROM ir_attachment WHERE res_field IS NOT NULL AND checksum IS NOT NULL
ORDER BY checksum, id
) t;
Duplicated images
The menus Duplicated Images and Remove Duplicated Images (Website → eCommerce → Products) are for administrators. On install, a hook fills the image checksum of the existing gallery images with one SQL update; to refresh it later from the shell:
env["product.image"]._dedup_backfill_checksums()
Before you start, see Configuration for the optional AI library and the system parameters.
The module covers three flows on the same product images: Remove background, Duplicated images and Recompression.
Important: the original image is not kept, neither when the background is removed nor when images are recompressed. Always check the preview before applying.
Remove background
Step 1 — Select the products and start the action
Go to Website → eCommerce → Products → Products and switch to list view. Tick the products whose photos you want to clean, then choose Actions → Remove Image Background. On a product, the action also covers the images of its eCommerce gallery.
Access rights: the action needs the Products: Create right. To modify gallery images you also need Sales: Administrator or Website: Restricted Editor; without them Apply stops with an access error.
Step 2 — Check the preview
When the selection has at most bg_sync_limit images (default 5), the wizard cuts them out on the
spot, writes nothing yet, and shows Before and After for each one. The limit counts
images, not products: the main image plus every gallery image of each product.
- Each row is one image: main image is the product's main picture, gallery image N is the N-th picture of its gallery. The After column shows the result on a checkerboard; the squares are the transparent area.
- Check that the product is complete (accessories, cap, funnel), that nothing is left around it and that white areas inside the product (the label) stayed opaque.
- Untick the rows whose result is not good and press Apply. Only ticked rows are written.
The wizard also sets how the result is framed: Frame in a Square with a Margin (%), and a
Background Color (empty = transparent, #FFFFFF = solid white). They start from the system
parameters and apply after Refresh Preview.
To make photos square without removing the background, choose the method Frame only (keep background): the product is centered in a square filled with the background color, and pieces smaller than Ignore Pieces Under (%) of the product (a logo in a corner) are left out of the square. It needs a photo on a plain background.
With the Automatic method, the wizard cuts by color when the image border has a single color and uses the AI model otherwise.
Step 3 — When the AI model loses part of the product
When the AI model is used on a photo with a uniform background, its result is compared with the
cut-out by color. If it left out at least bg_lost_warning percent of the product, the row shows a
warning in the Warning column and is unticked.
Choose another Method or AI Model and press Refresh Preview. Refresh rebuilds the preview and also the ticks. So first choose the method and press Refresh Preview, and only then untick what is not good, right before Apply.
Step 4 — The result on the product
After Apply, the product image (and its resized variants) is saved on a transparent background,
in WebP format (PNG if the server cannot encode WebP; JPEG if a solid bg_color is set). The
Background Removal status becomes Removed. On the shop, the product appears on the page background.
Step 5 — Many images: the queue
Above bg_sync_limit images, a live preview would take too long. The wizard only asks for
confirmation and sends the images to the Queue. The scheduled action Image Optimizer: remove
product image background processes them in batches of bg_batch, using the method from the system
parameters. An image that cannot be cut out stays unchanged and is marked Failed; the reason
appears only in the server log.
To find pending or failed images, use Filters → Add a custom filter on the product list, on the Background Removal field (Pending or Failed).
Tip: try a few images with the preview first, to see the result on your own catalog photos.
From the website editor — one picture
On the product page of the website, click Edit, then click the product picture. Under Background, click Remove Background (not the red Remove of Media, which deletes the picture). A dialog shows the picture before and after, on a checkerboard, with the warning of the method when there is one; the method can be changed there and the preview is refreshed. Apply writes the picture on the product, then the editor saves the page and reloads it, as for the standard Re-order and Remove buttons of product pictures. Cancel writes nothing.
The button appears only on product pictures (product, variant, gallery image), not on the pictures of the page (banners, blocks), and the change needs the right to modify the product. A variant without its own picture shows the picture of its product: the background is then removed on the product. In Odoo 20 the main picture of a product is also its first gallery picture: removing the background of one updates both.
Remove a watermark
Step 6 — Remove the watermark of your catalog images
Only on images whose watermark you have the right to remove (your own, or with the rights holder's written consent): the wizard opens with this reminder.
- In Website → eCommerce → Products → Products, list view, tick the products that carry the same watermark — the more, the better the watermark is learned — and choose Actions → Remove Watermark.
- Check the Detected Watermark: it is the logo the module found in the images.
- Check each image before and after; untick the ones that are not good, then Apply. Above
wm_sync_limitimages the selection is queued instead.
Duplicated images
Step 7 — Find the duplicates
Website → eCommerce → Products → Duplicated Images (administrator only). The list opens filtered on the groups that can be cleaned (Removable).
- Each row is an image content that is identical byte for byte. Copies is how many images have this content, Products is on how many products, Removable is how many copies repeat inside the same product.
- Removable is lower than Copies: one image always remains on each product.
- The Shared Across Products filter shows a picture used on several products. It is reported but never deleted.
- The Images button opens the images of the group.
Step 8 — Delete the duplicates
Website → eCommerce → Products → Remove Duplicated Images. The wizard shows how many contents have copies to delete, how many images will be deleted and kept, and the exact list. From each group (same content, same product) the image that appears first in the gallery stays; images with a video always stay. Remove Duplicates asks for confirmation and deletes permanently.
Recompression
Step 9 — Recompress oversized images
Go to Settings → Technical → Automation → Scheduled Actions and open Image Optimizer: recompress
oversized images. The action is inactive after installation. Run it first on a staging
database with Run Manually: one run takes the largest batch originals (default 50) above
min_size, shrinks them to max_dim pixels and re-encodes them (JPEG, or WebP when they have
transparency), then recompresses the same number of variants and cleans the filestore. The result
is kept only if it is smaller. Check the products with the largest images, then activate the action
on production.
The parameters are in Settings → Technical → Parameters → System Parameters (developer mode),
keys starting with deltatech_image_optimize.. Do not change force_jpeg: at 1, transparency
becomes black permanently.
20.0.1.14.1 (2026-11-19)
- The loading indicator of the background removal dialog uses the Odoo 20 spinner
(
oi oi-spin,autorenew) instead of the Font Awesome one, which no longer has a style.
20.0.1.14.0 (2026-10-22)
- Background removal wizard: new method Frame only (keep background), for product photos on a
plain background that are not square and show small in the shop list. The background stays; the
product is cropped and centered in a square filled with the background color (or the chosen
color), saved as JPEG. Pieces smaller than
bg_frame_min_islandpercent of the product (default 10, e.g. a logo in a corner) do not widen the square. - The wizard now has Frame in a Square, Margin (%) and Background Color, prefilled from
bg_crop,bg_marginandbg_color, so they can be changed per run; a queued selection still uses the system parameters.
20.0.1.13.2 (2026-10-21)
- Configuration: for rembg on odoo.sh, add
coverage>=7.6.1next torembg[cpu]in the requirements, notnumba<0.61as advised in 20.0.1.13.1. numba needscoverage.types.Tracer, added in coverage 7.6.1 (odoo.sh ships 7.4.4), while the pin on numba conflicts with the numpy required by the current rembg and makes the build fail while installing the requirements. Port of 19.0.1.13.2.
20.0.1.13.1 (2026-10-21)
- rembg installed but failing to import (on odoo.sh, numba 0.61+ with an older
coverageraisedAttributeError: module 'coverage.types' has no attribute 'Tracer') blocked the background removal dialog of the website editor, the wizard and the queue. It is now handled as rembg not installed: the error is logged once, the AI model is shown as not available and pictures on a plain background are still cut out by color. To use rembg on such a server, see 20.0.1.13.2. Port of 19.0.1.13.1.
20.0.1.13.0 (2026-10-21)
- Website editor: a product picture (product, variant or gallery image) gets Background → Remove Background. A dialog previews the picture before and after, with the method and its warning; Apply writes the picture on the product, then the editor saves and reloads the page. Pictures of the page itself (banners, blocks) do not get the button, and the change needs the right to modify the product. Port of 19.0.1.13.0.
- Background removal also works on the own picture of a variant (
image_variant_1920); a variant without its own picture is handled on its product. - The picture synchronized with the cut-out one (main picture of the product and first gallery picture) is also marked Removed, so the queue does not process it again.
20.0.1.12.5 (2026-10-16)
- Migration to Odoo 20. Product images now all live on the template and reach the variants through attribute values: duplicates are counted per template and attribute values (instead of template and variant). The main image of a template is also its first gallery image in Odoo 20; background and watermark removal process it once and recode both copies, and the optimizer does not recompress the synchronized copy again.
19.0.1.12.5 (2026-10-16)
- Development status raised from Beta to Production/Stable: the module has been in production use at customers for a long time.
19.0.1.12.4 (2026-10-12)
- Tests: the watermark tests now run in CI. They were skipped because the CI image has
no numpy; the repository gets a
test-requirements.txtwith numpy (numpy stays an optional dependency of the module). New tests cover the error and queue paths of watermark and background removal, recompression edge cases (unreadable input, palette images, PNG fallback without WebP, orphan attachments, failed writes) and the duplicate image report and wizard.
19.0.1.12.3 (2026-10-12)
- Readme: the description starts with the module title, like the other modules, and the
changelog uses one heading level for every version. The description began directly with
second-level headings, so the generated
README.rstjumped from level 2 to level 4 at Usage and the readme generator stopped on the whole repository.
19.0.1.12.2 (2026-10-09)
- IMAGE-001: animated PNG (APNG) and animated WebP images are no longer optimized. Only animated GIFs were left alone; the others were saved as their first frame and the animation was lost. Every animated image, whatever its format, is now skipped by both the original and the variant optimizer.
Older releases are listed in the module's HISTORY file.
Need help getting started?
Our 800+ apps on the Odoo Apps Store are used in Odoo implementations across Europe, the Americas, Asia and Africa — by companies we have never even met. That is the advantage of building modules that simply work.
Questions about this module? Write to us — the developers who build it will answer.
More apps by Terrabit
Other modules from the same publisher, built to work together. All apps →
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
eCommerce (website_sale)
• Website (website) • Discuss (mail) • Invoicing (account) |
| Lines of code | 2078 |
| Technical Name |
deltatech_image_optimize |
| License | OPL-1 |
| Website | https://www.terrabit.ro |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module
very good
very good
very good