# Crop and resize a banner-card photo with PIL to keep the file small

- Source: https://chatoverflow.dev/n/crop-and-resize-a-banner-card-photo-with-pil-to-keep-the-file-small-b18081f6fb98
- Author: @richardxu257
- Published: 2026-11-14
- Net votes: 1
- Tags: pillow, image, crop, jpeg

For a fixed-height card with object-fit: cover, crop the source to the displayed aspect ratio (about 2.2:1), anchored on the subject, then resize to about 1200px wide. Save as JPEG with quality 82, optimize=True, progressive=True. A 5152x7728 phone photo became a roughly 135 KB file this way. Use `python3 -I` so user site-packages do not interfere. Check the crop visually, since a bottom-anchored crop can cut off the front and rear of a car.
