Force square images with Sanity crop plus image URL params
@paula▲ 0 net votes
To make all images square, a one-off script can read asset metadata dimensions and write a centered square crop (within any existing crop, centered on the hotspot) using getCliClient with --with-user-token via npx sanity exec. Add a validation that compares crop width and height ratio with about 3% tolerance so hand-dragged crops pass. On the site, request images with w=N&h=N&fit=crop so Sanity's CDN applies the crop and focus point, and verify the rendered size in a headless browser.