eCommerce Image Centering Tool
Centre product photos on a clean canvas, cropped to the detected product, with batch download as a ZIP.
#about
Crops each product photo to the product and centres it on a fixed-size canvas, 600×600 by default.
OpenCV finds the subject by thresholding the greyscale image at 240 down to 200, falling back to adaptive Gaussian and Otsu thresholding.
Detection suits white or near-white backgrounds, and if nothing usable is found the whole image is fitted to the canvas uncropped.
The crop adds a 5% margin around the subject.
Streamlit app
- Platform
- Browser-based (no installation required)
- Input
- Product imagesOutput size and background settings
- Output
- Centered product images (ZIP for batch)
- Category
- E-commerce
Use cases
- Standardising product photos for marketplaces
- Adding consistent padding and backgrounds
- Correcting off-center product shots
- Batch processing catalog images
#features
- Cascading threshold detection (240, 230, 220, 200, then Adaptive and Otsu)
- Morphological cleanup with 5×5 kernels
- Crops to the detected subject plus 5% margin (contours over 3% of the image's pixel area)
- Output sizes: 600×600, 800×800, 1000×1000, or custom
- Padding 0-30% with hex colour picker
- Manual horizontal/vertical offset (±100px)
- JPEG/WEBP export with batch ZIP download
#how-to-use
- Upload product images (batch supported)
- Select output size and format (JPEG/WEBP)
- Configure padding and background color
- Preview detection with debug visualisation
- Adjust manual offsets if needed
- Download individual images or batch ZIP
#faq
- What kind of product photos does the detection work best on?
- Photos on white or near-white backgrounds. The tool separates subject from background by grayscale thresholding, trying cutoffs of 240, 230, 220 and 200 in turn, then falling back to adaptive Gaussian and Otsu thresholding. If no usable contour is found at any stage, the image is simply resized onto the canvas without recentring, so busy or dark backgrounds may come through unchanged.
- Does the tool crop my image?
- Yes. It crops to the combined bounding box of all detected contours plus a 5% margin, then rescales that crop onto the output canvas. Contours no larger than 3% of the image's pixel area are ignored as noise (the code compares against 1% of the RGB array size, which holds three values per pixel), so tiny detached elements such as faint shadows or small labels can be cropped out.
- Is transparency preserved in the output?
- No. Uploads are converted to RGB on load and output is always JPEG or WEBP on a solid background, chosen with the hex colour picker (white by default). If you upload a transparent PNG, the transparency is discarded before processing, which can also confuse subject detection.
- The subject is centred wrongly. How do I debug it?
- Tick 'Show detection visualization' in the results. It overlays a crosshair on the detected centre and shows the four binary threshold masks side by side, so you can see which thresholding pass fired and whether background clutter was picked up as part of the subject. You can then correct with the manual horizontal and vertical offset sliders (plus or minus 100px in 5px steps).
- How does batch download work?
- The ZIP download only appears when you upload more than one image, and the whole batch is exported in a single format (JPEG or WEBP) chosen at download time. Per-image format selection is available on the individual download buttons.
/contact
Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.