Image Cropping for Social Media: Aspect Ratios That Matter
Every social platform displays images differently. A perfectly composed landscape photo gets awkwardly clipped in an Instagram feed, and a vertical banner looks tiny in a Twitter timeline. Knowing the right aspect ratios eliminates guesswork and ensures your visuals appear as intended.
The Aspect Ratio Cheat Sheet
Here are the dimensions that matter most in 2026:
| Platform | Content Type | Aspect Ratio | Recommended Size |
|---|---|---|---|
| Feed post (square) | 1:1 | 1080 x 1080 | |
| Feed post (portrait) | 4:5 | 1080 x 1350 | |
| Story / Reel | 9:16 | 1080 x 1920 | |
| X (Twitter) | In-stream image | 16:9 | 1200 x 675 |
| Feed post | 1.91:1 | 1200 x 628 | |
| Story | 9:16 | 1080 x 1920 | |
| Feed post | 1.91:1 | 1200 x 628 | |
| YouTube | Thumbnail | 16:9 | 1280 x 720 |
| Open Graph | og:image | 1.91:1 | 1200 x 630 |
These are not arbitrary. Each platform's feed algorithm and card renderer is optimized for specific ratios. Images that do not match get center-cropped or letterboxed automatically.
Understanding Aspect Ratios
An aspect ratio describes the proportional relationship between width and height. The ratio 16:9 means the width is 1.78 times the height. When you crop an image, you are selecting a rectangular region that matches a target ratio.
In code, calculating the crop dimensions for a target ratio is straightforward:
function getCropDimensions(
sourceWidth: number,
sourceHeight: number,
targetRatio: number // width / height
): { width: number; height: number; x: number; y: number } {
const sourceRatio = sourceWidth / sourceHeight;
let cropWidth: number;
let cropHeight: number;
if (sourceRatio > targetRatio) {
// Source is wider than target: crop sides
cropHeight = sourceHeight;
cropWidth = Math.round(sourceHeight * targetRatio);
} else {
// Source is taller than target: crop top/bottom
cropWidth = sourceWidth;
cropHeight = Math.round(sourceWidth / targetRatio);
}
return {
width: cropWidth,
height: cropHeight,
x: Math.round((sourceWidth - cropWidth) / 2),
y: Math.round((sourceHeight - cropHeight) / 2),
};
}
// Example: crop a 4000x3000 photo for Instagram portrait (4:5)
const crop = getCropDimensions(4000, 3000, 4 / 5);
// { width: 2400, height: 3000, x: 800, y: 0 }
This centers the crop, which works for most images. For portraits or specific subjects, you may want to offset the crop toward the focal point.
The Canvas API Approach
In the browser, the Canvas API handles cropping without any server round trip:
function cropImage(
img: HTMLImageElement,
x: number, y: number,
width: number, height: number
): string {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d")!;
ctx.drawImage(img, x, y, width, height, 0, 0, width, height);
return canvas.toDataURL("image/jpeg", 0.9);
}
This runs entirely on the client. No files leave the user's machine, and the result is available as a data URL or Blob for download.
Smart Cropping: Focusing on the Subject
Center-cropping fails when the subject is off-center. Content-aware cropping detects the most important region using techniques like edge detection, face detection, or saliency maps.
CSS already supports this concept:
.profile-pic {
width: 200px;
height: 200px;
object-fit: cover;
object-position: top center; /* bias toward faces */
}
For programmatic smart cropping, libraries like smartcrop.js analyze the image and return optimal crop coordinates. This is especially useful when batch-processing user-uploaded photos.
Batch Cropping for Multiple Platforms
If you publish to several platforms, you need the same image in multiple crops. A simple automation script can generate all variants at once:
const platforms = [
{ name: "instagram-square", ratio: 1 / 1, size: 1080 },
{ name: "instagram-portrait", ratio: 4 / 5, size: 1080 },
{ name: "twitter", ratio: 16 / 9, size: 1200 },
{ name: "og-image", ratio: 1.91 / 1, size: 1200 },
];
platforms.forEach(({ name, ratio, size }) => {
const crop = getCropDimensions(sourceWidth, sourceHeight, ratio);
// Apply crop and resize to target size
console.log(`Generated ${name}: ${crop.width}x${crop.height}`);
});
Common Cropping Mistakes
- Ignoring safe zones. Some platforms overlay UI elements (like Instagram's gradient at the top of stories). Keep important content away from the edges.
- Upscaling after cropping. If the cropped region is smaller than the target size, the image becomes blurry. Start with the highest resolution source available.
- Forgetting retina displays. A 1080 px image looks sharp on a 1x display but soft on a 2x screen. Consider exporting at 2x for high-DPI devices.
- Cropping text too tightly. Headings and captions need breathing room. Leave at least 10% padding around text overlays.
Open Graph Images
Every page you share on social media should have a proper og:image tag. The recommended size is 1200 x 630 pixels (1.91:1 ratio):
<meta property="og:image" content="https://example.com/og-card.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
Test your cards with the platform's debugger tool before publishing.
Try our Image Cropper to crop images to any aspect ratio instantly — right in your browser, no upload required.