Compress to KB topic guide

Compress images for Twitter / X: hit the 5 MB image upload limit

Direct answer

When you attach still photos to an X (Twitter) Post or Direct Message through the API — or prepare files before you upload in the app — X’s media best-practices docs publish a 5 MB maximum for tweet_image and dm_image. That ceiling matches WhatsApp Cloud API image messages and LinkedIn share-box photos in megabytes only; supported types, validation paths, and multi-media rules differ. Animated GIFs use a separate tweet_gif/dm_gif budget (15 MB). Video exists on Posts but is out of scope here. If your export exceeds 5 MB, compress to a deliberate KB target before you publish.

Try the Compress to KB

What this workflow handles

Treat X API media best practices as the byte budget for still images on Posts and DMs. Supported image types are JPG, PNG, GIF, and WEBP. Image max file size is 5 MB for tweet_image and dm_image — the same for default accounts and X Premium per the published table. A Post can include up to four photos, or one animated GIF, or one video — not mixed arbitrarily; plan bytes per still image when you attach multiple photos. Animated GIFs (tweet_gif / dm_gif) allow up to 15 MB with extra constraints when relevant: resolution at most 1280×1080, at most 350 frames, total pixels (width×height×frames) at most 300 million, and file size at most 15 MB — compress still photos under 5 MB separately from GIF workflows. This page is file-size compression for still images, not canvas presets — for cross-network dimensions see social-media-image-resizer. Enter a Compress to KB target under 5120 KB (commonly 3500–4800 KB), quality-sweep at the current dimensions first, and downscale only if the quality floor still misses the budget. Beita’s Compress to KB uses a temporary analysis upload with no long-term storage; see the Privacy Policy for retention details.

Use Compress to KB with a target under 5120 KB (for example 3500–4800 KB) before you attach still photos to an X Post or DM. For cross-network width and height presets, see Social media image resizer. For Meta Cloud API WhatsApp image messages at the same 5 MB number, see Compress image for WhatsApp.

How to use it

  1. Open X API media best practices and note 5 MB for tweet_image and dm_image (JPG, PNG, GIF, WEBP); animated GIF tweet_gif/dm_gif allows 15 MB with separate resolution and frame rules.
  2. Confirm you are compressing still photos, not video — Posts allow up to four photos, or one animated GIF, or one video per the same doc summary.
  3. Pick JPEG for photographs and PNG or WEBP when your export path needs them; remember each photo in a multi-image Post must stay under 5 MB on its own.
  4. Enter a Compress to KB target under 5120 KB (commonly 3500–4800 KB), quality-sweep at the current dimensions first, and allow stepped downscale only if the quality floor still exceeds the budget.
  5. Upload or publish the compressed still image, confirm at or under 5 MB per file, and re-read docs.x.com if validation still fails.

Frequently asked questions

What is X’s still-image file size limit for Posts and DMs?

X API media best practices list a 5 MB maximum file size for tweet_image and dm_image (still images). Treat 5120 KB as the ceiling and aim slightly lower for encoding headroom before you upload or call the media APIs.

Which image formats does X accept for still photos?

The same best-practices page lists supported image types as JPG, PNG, GIF, and WEBP for image uploads. Pick the format that fits your content; JPEG remains the usual choice for photographs destined for Posts.

Is the 5 MB image limit different for X Premium?

Per X API media best practices, the 5 MB tweet_image and dm_image cap applies the same for default and X Premium in the published table. Compress under 5 MB regardless of subscription tier when you follow those API specs.

How many photos can I attach to one Post?

X’s media best practices state you can attach up to four photos, or one animated GIF, or one video per Post. When you attach multiple still images, each photo counts against the per-image limits — compress every file under 5 MB before upload.

What about animated GIFs — is the limit still 5 MB?

No. Animated GIFs use tweet_gif and dm_gif with a 15 MB maximum file size, plus resolution, frame, and pixel product limits documented on the same best-practices page. This guide focuses on still tweet_image/dm_image compression at 5 MB; treat GIF animation as a separate 15 MB workflow.

What KB target should I use in Compress to KB?

Start from 5120 KB (5 MB) and leave headroom: 3500–4800 KB is a practical target for a single still photo. Quality-sweep first at the current pixel dimensions; allow stepped downscale only if the quality floor still exceeds the budget. web.dev’s compress-images guide recommends experimenting with quality rather than assuming one universal setting.

Does this page cover video uploads on X?

No. Posts can include one video per the same best-practices summary, but video byte limits and encoding rules are a separate category. Use this page when you need still JPG/PNG/GIF/WEBP photos under the 5 MB tweet_image/dm_image cap.

How is X’s 5 MB limit different from WhatsApp’s and LinkedIn’s 5 MB caps?

All three publish 5 MB for still images on different products. compress-image-for-whatsapp covers Meta Cloud API JPEG/PNG image messages. compress-image-for-linkedin covers LinkedIn Help share-box photo uploads with dimension and aspect rules. compress-image-for-instagram covers Instagram Graph API 8 MB JPEG feed, Story, and Reels cover uploads. compress-image-for-notion covers Notion Help 5 MB inline PNG/JPG display even on paid plans. This page covers X API tweet_image/dm_image JPG/PNG/GIF/WEBP for Posts and DMs plus separate 15 MB animated GIF limits — not WhatsApp messages, LinkedIn posts, Instagram Graph publishing, or Notion pages.

How is this different from the GitHub, Discord, Telegram, email, and general KB guides?

compress-image-for-github covers GitHub Docs 10 MB image and GIF attachments. compress-image-for-discord covers Discord Support 20 MB free per-file chat uploads. compress-image-for-telegram covers Telegram Bot API sendPhoto 10 MB inline photos. compress-image-for-email covers Gmail and Outlook.com 25 MB message attachment totals. compress-image-for-whatsapp covers Meta Cloud API 5 MB image messages. compress-image-for-linkedin covers LinkedIn Help 5 MB share photos. compress-image-for-instagram covers Instagram Graph API 8 MB JPEG feed, Story, and Reels cover uploads. compress-image-for-notion covers Notion Help 5 MB inline PNG/JPG display. compress-image-to-kb covers forms and marketplaces (GOV.UK, LinkedIn profile 8 MB, Shopify) without isolating X media rules. For preset dimensions across networks, use social-media-image-resizer — not this byte-budget page. Same Compress to KB tool; different destination budget.

Sources

Explore the compress to kb topic cluster

This guide covers X API still-image size for Posts and DMs. Related guides cover general KB budgets, email, WhatsApp, LinkedIn share photos, Instagram Graph JPEG caps, Notion inline image caps, GitHub, Discord, Telegram caps, and the Compress to KB tool.

Related guides

All compress to kb guides