【Claude】Request too large / Image too large / Unable to resize / PDF 报错已解决(4合1)
【Claude】Request too large / Image too large / Unable to resize / PDF 报错已解决4合1关键词Claude Code、Request too large 30MB、Image was too large、Unable to resize image、PDF too large、粘贴大文件、图片尺寸、双 Esc报错一Request too large (max 30 MB)现象Request too large (max 30 MB). Double press esc to go back and remove or shrink the attached content.根因这是HTTP 请求体的大小限制30 MB和上下文 Token 数限制Prompt is too long是两个独立的限制。触发场景向 Claude Code 粘贴了超大的文本内容比如整个大文件的全部内容拖入了超大的二进制文件附加了大量图片。注意这是字节大小限制发生在请求发出之前客户端预检不会到达 API。解法双按 Esc回退到添加超大内容之前的那一轮然后改用以下方式# 不要粘贴文件内容按路径引用 请帮我分析这个文件/Users/你/project/large-file.ts按路径引用时Claude Code 会分块读取文件而不是把整个内容一次性放进请求体。报错二Image was too large现象Image was too large. Double press esc to go back and try again with a smaller image. API Error: 400 ... image dimensions exceed max allowed sizeAPI 的图片限制场景最长边上限单张图片上下文里图片少8000 像素上下文中有多张图片时2000 像素每张v2.1.142 的自动处理在 v2.1.142 及以后Claude Code 会自动把无法处理的图片替换为文本占位符并重试后续消息通常成功。这个错误消息在新版本里基本只会闪一下。v2.1.142 之前的旧版本粘贴的图片可能一直留在对话里每次请求都报这个错。解法双按 Esc回退到添加图片之前的那一轮。解法在粘贴之前先缩小图片# macOS用 sips 缩小 sips -Z 2000 input.png --out output.png # 最长边缩到 2000px # 或用 ImageMagick convert input.png -resize 2000x2000\ output.png拍屏幕截图时截相关区域而不是整个屏幕或者用压缩率更高的 JPEG 代替 PNG。报错三Unable to resize image现象多种变体Unable to resize image — image processing is unavailable and dimensions could not be read from the file header. Please convert the image to PNG, JPEG, GIF, or WebP. Unable to resize image — dimensions exceed the 2000x2000px limit and image processing failed. Please resize the image to reduce its pixel dimensions. Unable to resize image (… raw, … base64). The image exceeds the … API limit and compression failed. Please resize the image manually or use a smaller image. Unable to resize image — could not verify image dimensions are within the 2000x2000px API limit.根因Claude Code 通常会自动调整大型图片以适应 API 限制但本机图像处理器native image processor加载失败或返回错误时自动调整就无法完成。四种变体分别对应格式不被支持dimensions could not be read图片是不常见的格式如 BMP、TIFF、WebP 变种无法读取尺寸超限且处理失败尺寸超过 2000×2000但压缩失败大小超 API 限制且压缩失败文件字节数超限无法验证尺寸不确定是否超限因此拒绝。解法根据消息内容对号入座Please convert the image to PNG, JPEG, GIF, or WebPconvert input.bmp output.pngdimensions exceed the 2000x2000px limit 手动缩小到 2000px 以内后重新粘贴。无法验证尺寸也转成标准格式PNG/JPEG后重试。报错四PDF too large / password protected / not valid现象PDF too large (max 100 pages, 32 MB). Try splitting it or extracting text first. PDF is password protected. Try removing protection or extracting text first. The PDF file was not valid. Try converting to a different format first.API 对 PDF 的限制限制维度上限页数100 页文件大小32 MB密码保护不支持解法PDF 太大超过 100 页 / 32 MB不要直接附加整个 PDF用 Claude Code 的 Read 工具按页范围读取请用 Read 工具读取这个 PDF 的第 1 到 50 页/path/to/large.pdf或者先提取文本# 使用 pdftotext pdftotext large.pdf output.txt再按路径引用提取出来的output.txt。PDF 有密码先在源应用里导出为无密码版本或用工具去除密码需要有合法权限。PDF 无效在源应用如 Adobe Acrobat、macOS 预览里重新导出或转成图片再处理convert -density 150 document.pdf document-%d.jpg总结对照报错限制类型核心解法Request too large (30 MB)HTTP 请求体字节数双 Esc 回退 按路径引用代替粘贴Image too large图片像素尺寸缩至 2000px 以内Unable to resize image图片格式/尺寸验证失败转为 PNG/JPEG 手动缩小PDF too large / protected / invalidPDF 页数/大小/密码/格式按范围读取 / pdftotext / 重新导出所有这类错误的恢复方式都一样双按 Esc 回退到添加大内容之前再换一种轻量的方式引用内容。参考Claude Code 官方《错误参考》请求错误章节。

相关新闻