TL;DR: I have created a drag and drop shell script that works on Mac/Linux, which can get the product photo in the right size you want or align with same white margin, with help from a few open source library from Rust .
https://gist.github.com/jimmyctk/94c072b18617315fe79a95f730f59dd3
Background
Have you ever been annoyed that some product photos in your catalog look bigger and some look smaller? Do you want them in the same size?
Example1 | Example2 |
Deliverables
The processing of 100 1000x1000px images can be done in 96.1s.
./image-optimize.sh 1000 100 96.10s user 27.26s system 269% cpu 45.724 total
Before | After |
How it works
The code simply has 3 steps:
- Detect the bounding box of the object, crop it
- Resize (shrink/enlarge) the cropped image to targeted resolution
- Add the white border back to the image with desired width
Reference
https://crates.io/crates/auto-image-cropper