Resizing sounds like one number. Then it turns out to be two numbers that have to agree, and making an image bigger is a different job from making it smaller.
macOS has a resizer built in, no install required. -Z fits the image inside a
box on its longest edge, keeping the aspect ratio:
sips -Z 1200 photo.jpg --out photo-small.jpg
With ImageMagick, on any platform:
magick photo.jpg -resize '1200x1200>' photo-small.jpg
The > inside the quotes means "only if it is bigger", so running it over a
folder never enlarges the small ones by accident.
Keep the ratio, or accept the squash
Every image has an aspect ratio. Set the width and height separately and you will break it. A 4000 × 3000 photo (4:3) forced into a 1200 × 1200 square comes out visibly squashed.
The answer is to set one dimension and let the other follow:
new height = original height × (new width ÷ original width)
3000 × (1200 ÷ 4000) = 900
So 4000 × 3000 becomes 1200 × 900. Every command and tool on this page does that sum for you. It is only worth knowing so you can spot it when a tool gets it wrong.
If you really need a square from a rectangle, crop it instead of resizing. Cropping cuts off the parts that do not fit. Resizing distorts everything to make it fit.
Down is safe, up is not
Downscaling throws pixels away. The resampler averages neighbouring pixels into one. That has a clear right answer, and the result looks correct.
Upscaling has no extra detail to work with, so it makes up pixels by blending the ones it has. That looks soft. Doubling is sometimes fine. Quadrupling looks like exactly what it is.
Keep the full-size file. A 400px thumbnail made from an 800px copy of a 4000px original gets softened twice. Going back to the original costs nothing and looks better.
Sizes that are actually useful
| Use | Long edge |
|---|---|
| Thumbnail | 300–400px |
| Blog image, in the text column | 1200–1600px |
| Full-width hero | 2000px |
| Print, at 300 DPI | width in inches × 300 |
Web sizes assume high-density screens, which need roughly double the displayed size. That is why a 700px-wide column still wants a 1400px image.
- Work on a copy of the folder, not the originals.
- Decide the long edge from the table above, and use a "shrink only" flag so already-small files are left alone.
- Resize first, then compress. Compressing first is wasted effort, because the resize re-encodes the file anyway.
- Spot-check the smallest and the most detailed result, not just the first one.
With ImageMagick, that whole loop is one line:
magick mogrify -path ./resized -resize '1600x1600>' ./originals/*.jpg
mogrify -path writes to a different folder, which stops it overwriting your
originals.
Then make it smaller still
Resizing is the biggest single saving, but the file can usually shrink further with no visible change. That is compression, and it is a separate step.