Telegram error 400: Bad Request: PHOTO_INVALID_DIMENSIONS
Last verified against Telegram Bot API reference
Bad Request: PHOTO_INVALID_DIMENSIONSWhat error 400 means
sendPhoto (or a photo inside sendMediaGroup / InputMediaPhoto) was given an image whose dimensions Telegram will not accept as a photo. The Bot API documents two constraints: the photo's width and height must not exceed 10000 in total, and the width-to-height ratio must be at most 20. Very tall screenshots, long receipts, panoramas and banner strips break the ratio rule; huge scans break the sum rule.
The error is a raw server identifier, so there is no further detail. The file itself is fine as bytes; it is the image geometry that fails. Telegram's photo pipeline re-encodes and thumbnails images, and these limits protect that pipeline.
Sending the very same file with sendDocument works, because documents are not re-encoded and have no dimension rules.
What it looks like
{"ok":false,"error_code":400,"description":"Bad Request: PHOTO_INVALID_DIMENSIONS"}Why it happens
- A long vertical screenshot or receipt (ratio above 20:1).
- A panorama or wide banner.
- A high-resolution scan where width + height exceeds 10000 pixels.
- Programmatically generated images (charts, tables) with extreme aspect ratios.
How to fix Telegram error 400
- 1Read the image dimensions before sending; if ratio > 20 or width+height > 10000, send as a document.
- 2Alternatively resize or split the image server-side to fit the photo rules.
- 3For generated charts, constrain the canvas aspect ratio at render time.
- 4Keep the original for documents so quality is preserved.
How to stop it recurring
Route all outbound images through a check that decides photo vs document based on the documented geometry rules. Prefer document for user-uploaded content of unknown shape, and photo only for thumbnails and images you control. When you relay images between users, keep the original file_id and resend it with the same media type Telegram assigned, which sidesteps re-validation entirely.
Byte-size ceilings are enforced separately and produce file is too big; an image can pass one check and fail the other. Both sets of numbers, with the documented source lines, are under file and media limits. Libraries raise their generic 400 class here, so match the uppercase identifier in the description.
Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.
Related codes
Error 400 - quick answers
What does Telegram error 400 mean?
sendPhoto (or a photo inside sendMediaGroup / InputMediaPhoto ) was given an image whose dimensions Telegram will not accept as a photo . The Bot API documents two constraints: the photo's width and height must not exceed 10000 in total, and the width-to-height ratio must be at most 20. Very tall screenshots, long receipts, panoramas and banner strips break the ratio rule; huge scans break the sum rule.
How do I fix Telegram error 400?
1. Read the image dimensions before sending; if ratio > 20 or width+height > 10000, send as a document. 2. Alternatively resize or split the image server-side to fit the photo rules. 3. For generated charts, constrain the canvas aspect ratio at render time. 4. Keep the original for documents so quality is preserved.
Should I retry after error 400?
No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.
Stop debugging Telegram by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.