A tall lamp needs space on the sides of a square. Wide headphones need space above and below. Keep their proportions and put them on the same size canvas with margins you can control.
Set aside a portrait sample, a wide one and a photo where the product nearly touches an edge. Run those three before exporting the whole folder. Check the photos after orientation metadata has been applied. A portrait photographed through a rotated camera can have different file dimensions from the way it appears in your editor.
Choose what fills the square
| Goal | Operation | What to check |
|---|---|---|
| Fit every pixel and allow a variable final shape | Resize to fit within the maximum dimensions | The output may be narrower or shorter than the requested box |
| Keep every part of the subject on a fixed canvas | Fit and pad the remaining space | The margin color should match the outer background |
| Fill the fixed canvas edge to edge | Resize proportionally to cover the box and crop | Handles, straps and controls can leave the crop |
The ImageMagick resizing guide describes resizing inside the requested bounds while keeping aspect ratio, and using geometry options to fill the bounds. The sharp resizing documentation uses contain for proportional fit with padding and cover for proportional scaling with a crop. A fill operation that ignores aspect ratio can visibly distort the subject.
Make one padded test batch
This example assumes ImageMagick 7 and files named with a lowercase .jpg extension in incoming. Start with a fresh ready-export directory. The resize fits the image inside 1,200 × 1,200, with the quoted > flag preventing enlargement. The extent operation centers that resized image on a square white canvas.
mkdir ready-export || exit 1
for product_source in ./incoming/*.jpg; do
[ -f "$product_source" ] || continue
product_name=${product_source##*/}
magick "$product_source" -auto-orient -resize '1200x1200>' \
-background white -gravity center -extent 1200x1200 \
"./ready-export/$product_name" || exit 1
done
Keep the loop's input separate from its output. Look for the seam between an off-white background and a white pad. A visible seam can come from the canvas color even if the product's shape is correct. Choose the padding color that fits the product treatment or prepare a background that blends consistently. When a client requires a full crop, test an individual image with slightly different crop placement if centered coverage cuts a feature.
Take an image that measures 1,800 by 900. The resize produces 1,200 by 600 before padding. The centering step adds 300 pixels of white above and below. A small image can keep its original size inside the canvas under the same no-enlargement rule.
Open the resulting square for each of the three samples. Check canvas dimensions and compare a familiar proportion, such as a round watch face. Then check the tips and edges at the expected storefront size. Count the exported files and inspect names before handing the batch to a client.
Compare a tall sample and a wide one
Use the shop's intended page size, then work back to the output pixels. In a square catalog the outside shape can match even when the subjects are very different. A tall lamp needs space to its left and right, a wide bag needs room above and below, and a watch may need a close crop for its dial. Mark where each subject could lose a useful feature. Proportional fit with padding lets the whole product remain visible. A proportional cover crop is a separate choice for a hero image that must touch the edges.
Try a second numeric example. A portrait source 900 pixels wide and 1,800 high would become 600 by 1,200 if scaled proportionally to fit the sample square. Centering leaves margins of 300 pixels at its sides. If the photographed product is already near the edge, the output can still look off-center because the source framing is subjective. The geometry centers the entire resized image. It does not inspect the subject. Correct the crop or alignment for that image before sending it through the general batch.
For a smaller source made intentionally at 800 by 800, the command's no-enlargement flag leaves it that size before padding. If a client needs the product to fill more of the canvas, decide whether to keep the native detail with more margin, request a higher-resolution source, or allow controlled enlargement on those files. Inspect small text and hard edges before accepting the enlarged copy.
Verify orientation and background before processing a folder
Check a portrait image whose camera stored an orientation flag. Make sure the output is upright in the shop and that the small thumbnail uses the same dimensions. The sample applies orientation before resizing and positioning. If a renderer ignores the orientation or a variant re-encodes it in another step, compare the generated file with the actual page before rerunning every image.
Pick an off-white or translucent background to test the pad color. A white margin can look like a border against a slightly warm product photo. If the original has transparency and the destination sends a JPEG, choose and test a matte that matches the site. Use separate commands or presets for files that still require transparency. Keep those cases out of an ordinary JPEG folder until you have chosen a compatible output.
Try the sample loop with a harmless directory before a real batch. Confirm that only the intended source files are selected. As written, it matches lowercase JPG file names. If the usual input includes uppercase extensions or other formats, list those and adjust the selection and conversion deliberately. Handle a failed file before repeating the operation. With a fresh destination, leave incomplete results in a test folder until you know which files succeeded.
Approve the contact sheet and the live gallery
Review the samples side by side at the actual card size. A round object can show obvious stretching, while comparing a handle or strap checks whether a crop left out something the customer expects. Count exports and spot-check the correspondence between the filenames and the products. Use a narrow browser to see whether the site imposes an additional crop on top of the prepared square. The three-card crop guide explains how to test that framing before handing over multiple variants.
Save the width, height, margin color and resizing method alongside the approved files. For a job with mixed needs, label any exceptions and keep their inputs so they can be reproduced. Reopen one representative completed image after the upload and check that its proportions and background agree with the prepared asset.


