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.
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
- 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.
- 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.
- 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.
- 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.
- 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. compress-image-for-wordpress covers WordPress Media Library upload limits and the 2560 px big-image threshold. compress-image-for-facebook covers Meta Help Center Facebook photo uploads (15 MB, PNG under 1 MB). compress-image-for-pinterest covers Pinterest Help web Image Pin uploads (20 MB). compress-image-for-youtube covers YouTube Help custom thumbnail MB limits. compress-image-for-threads covers Threads API 8 MB JPEG/PNG image posts. compress-image-for-bluesky covers Bluesky post embeds at 2,000,000 bytes per blob. 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, Notion pages, WordPress Media Library uploads, Facebook timeline photos, Threads API image posts, or Bluesky post embeds.
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-for-wordpress covers WordPress Media Library upload limits and the 2560 px big-image threshold. 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
- X API — Media best practices: https://docs.x.com/x-api/media/quickstart/best-practices — JPG/PNG/GIF/WEBP; tweet_image/dm_image 5 MB max; tweet_gif/dm_gif 15 MB max with resolution/frame limits; up to 4 photos or 1 GIF or 1 video per Post.
- web.dev — Compress images: https://web.dev/articles/compress-images — Experiment with quality settings; there is no one universal compression setting.
- Pillow — Image.save (JPEG quality, optimize): https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html#jpeg — JPEG quality and optimize parameters used in the quality sweep behind Compress to KB.
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, WordPress Media Library caps, Facebook Help photo upload caps, GitHub, Discord, Telegram caps, and the Compress to KB tool.
Related guides
-
Compress image to KB
General hard byte-budget workflow for forms and marketplaces.
-
Compress images for email
Gmail and Outlook.com 25 MB attachment caps.
-
Compress images for WhatsApp
Meta Cloud API 5 MB JPEG/PNG image-message cap.
-
Compress images for GitHub
GitHub Docs 10 MB cap for images and GIFs on issues and pull requests.
-
Compress images for Discord
Discord Support 20 MB free per-file upload cap.
-
Compress images for Telegram bots
Telegram Bot API sendPhoto 10 MB cap for inline bot photos.
-
Compress images for LinkedIn posts
LinkedIn Help 5 MB cap for share-box photo uploads.
-
Compress images for Instagram
Instagram Graph API 8 MB JPEG cap for feed, Story, and Reels cover.
-
Compress images for Notion
Notion Help 5 MB cap for inline PNG/JPG display (all plans).
-
Compress images for WordPress
WordPress Media Library 2560 px big-image threshold and PHP upload_max_filesize limits.
-
Compress images for Facebook
Meta Help Center 15 MB photo uploads; keep PNG under 1 MB to avoid pixelation.
-
Compress images for Pinterest
Pinterest Help 20 MB web Image Pin max; BMP, JPEG, PNG, TIFF, WEBP.
-
Compress images for YouTube
YouTube Help custom thumbnails: 50 MB on desktop; 50 MB mobile video, 10 MB mobile podcasts; JPG or PNG.
-
Compress images for Threads
Threads API image posts: 8 MB max JPEG or PNG; width 320–1440 px, aspect ratio up to 10:1.
-
Compress images for Bluesky
Bluesky post embeds: 2 MB max per image blob (image/*); up to 4 images; alt text required.
-
Compress to KB tool
Set a KB target and download a file under budget.
All compress to kb guides
- Compress image to KB: hit a hard file-size limit
- Compress images for email: hit Gmail and Outlook attachment caps
- Compress images for WhatsApp: hit the 5 MB image message cap
- Compress images for GitHub: hit the 10 MB image and GIF cap
- Compress images for Discord: hit the 20 MB free upload cap
- Compress images for Telegram bots: hit the sendPhoto 10 MB cap
- Compress images for LinkedIn posts: hit the 5 MB photo share limit
- Compress images for Instagram: hit the 8 MB JPEG upload limit
- Compress images for Notion: stay under the 5 MB inline limit
- Compress images for WordPress: Media Library size and big-image rules
- Compress images for Facebook: file size and format before upload
- Compress images for Pinterest: hit the 20 MB web Image Pin cap
- Compress images for YouTube: custom thumbnail file-size limits
- Compress images for Threads: hit the 8 MB image post limit
- Compress images for Bluesky: hit the 2 MB post embed limit
- Compress images for TikTok: hit the 20 MB photo upload limit
- Compress images for Shopify: hit the 20 MB and megapixel upload limits
- Compress images for Mastodon: hit the 16 MB post attachment limit
- Compress images for Slack: byte size and inline preview limits
- Compress images for eBay: hit the 12 MB listing photo limit
- Compress images for Etsy: stay under the 1 MB upload reliability tip
- Compress images for Medium: hit the 25 MB story-editor limit
- Compress images for Google Business Profile: fit 10 KB–5 MB photo rules
- Compress images for Wix: Media Manager limits and practical upload ceilings
- Compress images for Webflow: 4 MB Assets limits and upload prep
- Compress images for Squarespace: 20 MB cap and 500 KB performance recommendation
- Compress images for Ghost: Ghost(Pro) plan caps (5 MB–1 GB) and self-hosted 50 MB nginx default
- Compress images for Gumroad: 50 MB cover limit and thumbnail prep
- Compress images for beehiiv: 5 MB newsletter uploads, 1200×630 thumbnails, and 10 MB community posts
- Compress images for Mailchimp: 1 MB Content Studio uploads, 1024 KB targets, and legacy vs new builder widths
- Compress images for Kit: smaller-than-25 MB gallery, form/LP sizes, and email look-best width
- Compress images for Klaviyo: 10 MB email ceiling, 1024 KB load targets, form 5120 KB, and full-width dimensions
- Compress images for MailerLite: 10 MB File manager, 1024 KB campaign prep, GIF 4 MB, and width rules
- Compress images for Brevo: 5 MB Content library, layout widths, and HTML/attachment contrast
- Compress images for Substack: official sizes, PNG email banners, and dimension-first prep
- Compress images for Google Ads: 5120 KB JPG/PNG assets, aspect ratios, and surface-specific rows