AI change background, keep product same — verify with compare
Swap only the background of a product photo, then crop the product and label and run ImageMagick compare to catch a changed shape or letter.
A label that reads M0SS instead of MOSS slips past you in a thumbnail. Even when you ask for a background change only, an editing model may redraw the bottle's proportions, the cap or the label text. Block that in the prompt, then compare the pixels.
[1] Write the one thing to change and a list of things to keep. Google's Gemini image docs (Image generation) frame partial edits as "change only [element] in the provided image, keep the rest exactly the same". The prompt below uses that frame and names the parts of a product that tend to drift.
Using the provided image, change only the background to {a wooden shelf covered with fallen autumn leaves, warm late-afternoon light}.Keep everything else in the image exactly the same, preserving the original style, lighting, and composition.Do not change the product in any way:- the bottle's shape, proportions, size and position in the frame- the cap's shape and color- every letter on the label: "{MOSS}" and "{30 ml}", same font, same spacingKeep the image size at {800x1000} pixels.[2] For glass, know where the background shows through. A clear or reflective bottle should change color inside when the background changes; that difference is not a defect. Check opaque parts such as the label, and the bottle outline, separately.
[3] The comparison below uses hand-made test images. original.png is a bottle drawn with convert; edit-a.jpg changes only the background; edit-b.jpg changes the background and swaps the label's letter O for the digit 0. Both edits were saved as JPEG (quality 85) and enlarged. They are not AI output. Check the sizes first.
$ identify -format "%f %wx%h\n" original.png edit-a.jpg edit-b.jpgoriginal.png 800x1000edit-a.jpg 896x1120edit-b.jpg 896x1120If the edit came back at a different size, scale it to the original first. The ! forces the exact size. If the aspect ratio itself differs, the product has been stretched and the image fails right there.
$ convert edit-a.jpg -resize 800x1000! edit-a.png$ convert edit-b.jpg -resize 800x1000! edit-b.png[4] Comparing the whole image tells you nothing: the new background makes about 776,000 of the 800,000 pixels differ.
$ compare -metric AE original.png edit-a.png null:776473[5] Crop to the inside of the product. Read the coordinates of a rectangle inside the bottle body (no background in it) from an image viewer, and crop all three images at the same spot: 280×440 starting at (260,375) here.
$ for f in original edit-a edit-b; do convert $f.png -crop 280x440+260+375 +repage $f-body.png; done$ compare -metric AE original-body.png edit-a-body.png null:108107$ compare -metric AE original-body.png edit-b-body.png null:107558With no tolerance, the tiny color shifts from JPEG and resizing count too, and the untouched edit-a looks no better than edit-b. Add -fuzz 10% to treat small color differences as equal.
$ compare -metric AE -fuzz 10% original-body.png edit-a-body.png null:1713$ compare -metric AE -fuzz 10% original-body.png edit-b-body.png null:4050The 1,713 pixels left in edit-a are resize traces along the letter edges; edit-b has more than twice that. How much trace remains depends on the editor and the scale factor, so no single number works as a pass mark. Use the numbers to pick which results to inspect, and decide with the diff image in step 6.
[6] Make a diff image of the label. Give compare a third file name and it paints differing pixels red.
$ convert original.png -crop 220x140+290+520 +repage original-label.png$ convert edit-b.png -crop 220x140+290+520 +repage edit-b-label.png$ compare -metric AE -fuzz 10% original-label.png edit-b-label.png label-diff.png2977In label-diff.png, resize traces show as thin lines along letter outlines. A changed letter is filled in completely. In this test, the SS after the 0 is filled too: the digit is narrower than the letter O, so the following letters shifted.
| Where | How | Sign of a change |
|---|---|---|
| Size | identify | Aspect ratio differs from the original |
| Bottle outline | Overlay original and result at 50% opacity | Shoulder or base line appears doubled |
| Body interior | compare with -fuzz | Clearly higher than the other results |
| Label text | Diff image, then zoom in and read letter by letter | Whole letter shapes filled |