jackwener/OpenCLI · error · ArgumentError
文字配图模式追加的图片不支持 .gif(编辑器图片入口只接受 jpg/jpeg/png/webp)
Error message
文字配图模式追加的图片不支持 .gif(编辑器图片入口只接受 jpg/jpeg/png/webp)
What it means
ArgumentError thrown when text-image (文字配图) mode is used but one of the supplied --images files has a .gif extension. The editor-page image input on XHS only accepts jpg/jpeg/png/webp, so the CLI rejects gif up front rather than failing mid-automation.
Source
Thrown at clis/xiaohongshu/publish.js:1211
const cards = cardText
? cardText.split(CARD_TEXT_DELIM).map((s) => s.trim()).filter(Boolean)
: [];
const cardStyle = kwargs['card-style'] ? String(kwargs['card-style']).trim() : '';
const isTextImage = cards.length > 0;
// ── Validate inputs ────────────────────────────────────────────────────────
if (!title)
throw new ArgumentError('--title is required');
if (title.length > MAX_TITLE_LEN)
throw new ArgumentError(`Title is ${title.length} chars — must be ≤ ${MAX_TITLE_LEN}`);
if (!content)
throw new ArgumentError('Positional argument <content> is required');
if (!isTextImage && imagePaths.length === 0)
throw new ArgumentError('Provide --card-text (text-image mode) or --images (upload mode); neither was given.');
if (imagePaths.length > MAX_IMAGES)
throw new ArgumentError(`Too many images: ${imagePaths.length} (max ${MAX_IMAGES})`);
// The editor-page image input (text-image append) rejects gif.
if (isTextImage && imagePaths.some((p) => path.extname(p).toLowerCase() === '.gif'))
throw new ArgumentError('文字配图模式追加的图片不支持 .gif(编辑器图片入口只接受 jpg/jpeg/png/webp)');
// Validate image paths before navigating (fast-fail on bad paths / unsupported formats)
const absImagePaths = validateImagePaths(imagePaths);
// ── Step 1: Navigate to publish page ──────────────────────────────────────
await page.goto(PUBLISH_URL);
await page.wait({ time: 3 });
// Verify we landed on the creator site (not redirected to login)
const pageUrl = await page.evaluate('() => location.href');
if (!pageUrl.includes('creator.xiaohongshu.com')) {
throw new Error('Redirected away from creator center — session may have expired. ' +
'Re-capture browser login via: opencli xiaohongshu creator-profile');
}
// ── Step 2: Select 图文 (image+text) note type if tabs are present ─────────
const tabResult = await selectImageTextTab(page);
const surface = await waitForPublishSurfaceState(page, tabResult?.ok ? 5_000 : 2_000);
if (surface.state === 'video_surface') {
await page.screenshot({ path: '/tmp/xhs_publish_tab_debug.png' });
const detail = tabResult?.ok
? `clicked "${tabResult.text}"`View on GitHub (pinned to 49907e53dc)
Solutions
- Convert the .gif to .png or .webp (e.g. ffmpeg -i in.gif out.png or magick in.gif out.png)
- Remove .gif files from the --images list
- For animated content, use upload mode --images without --card-text, or post as a video instead
Example fix
// before --card-text "a|b" --images "./meme.gif" // after magick ./meme.gif ./meme.png --card-text "a|b" --images "./meme.png"
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = ['.jpg', '.jpeg', '.png', '.webp'];
const bad = imagePaths.filter(p => !ALLOWED.includes(path.extname(p).toLowerCase()));
if (bad.length) throw new Error(`Unsupported formats: ${bad.join(', ')}`); Type guard
function isEditorSupportedImage(p) {
return ['.jpg', '.jpeg', '.png', '.webp'].includes(path.extname(p).toLowerCase());
} Try / catch
try {
await publish(page, { 'card-text': cards, images: imagesFlag, ...rest });
} catch (e) {
if (String(e.message).includes('.gif')) {
console.error('Convert gif to png/webp before text-image publishing');
}
throw e;
} Prevention
- Filter or convert gifs out of image lists before publishing
- Standardize exports to jpg/png/webp
- Pre-validate extensions for any programmatic image pipeline feeding the CLI
When it happens
Trigger: Running publish with --card-text (isTextImage true) where any path in --images ends with '.gif' (case-insensitive extension check).
Common situations: Exporting animated stickers/memes as gifs and mixing them into the image list; screenshot tools defaulting to gif; not knowing the XHS text-image editor's format restriction (it differs from the plain upload flow).
Related errors
- 不支持的视频格式: ${ext}(支持 mp4/mov/avi/webm)
- Failed to read image dimensions for ${filePath}
- Unsupported image format "${ext}". Supported: jpg, png, gif,
- Unsupported image format "${ext}". Supported: jpg, png, gif,
- Unsupported image format "${ext}". Supported: jpg, jpeg, png
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6d5f806ae1d4e010.
Report an issue: GitHub.