Screenshot format writes URL text to file instead of downloading image binary
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- node.js, typescript
- Domain
- cli
Research direction
Start with handleScrapeCommand in src/commands/scrape.ts and handleScrapeOutput plus formatScreenshotOutput in src/utils/output.ts. Reproduce the single-URL command from the issue, then compare it with the binary-writing path in handleAllScrapeCommand. Done means an image output contains valid downloaded PNG or other image bytes rather than the screenshot URL text.
Written by the indexing model from the issue text.
Description
Bug
When using firecrawl scrape --format screenshot -o output.png, the CLI writes the screenshot URL as plain text to the output file instead of downloading the actual PNG image. This produces a corrupt file that appears to be a PNG but is actually a small text file containing the Firecrawl CDN URL.
Reproduction
firecrawl scrape "https://example.com" --format screenshot -o screenshot.png
file screenshot.png # Reports: ASCII text, not PNG image data
cat screenshot.png # Shows: "Screenshot: https://..."
Expected behavior
The CLI should fetch the image from the screenshot URL and write the binary data to the output file (like handleAllScrapeCommand already does correctly for multi-URL scrapes).
Root cause
In src/commands/scrape.ts, handleScrapeCommand delegates to handleScrapeOutput in src/utils/output.ts. For a single screenshot format, handleScrapeOutput calls formatScreenshotOutput() which returns the URL as text, then writeOutput() writes that text string to the file with utf-8 encoding.
The multi-URL code path (handleAllScrapeCommand in the same file, ~line 470) correctly handles this by fetching the URL and writing the binary buffer:
const response = await fetch(result.data.screenshot);
if (response.ok) {
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync(filepath, buffer);
}
Suggested fix
In handleScrapeCommand, before calling handleScrapeOutput, check if the output is a single screenshot format going to an image file extension. If so, fetch the binary and write it directly:
const isScreenshotOnly = effectiveFormats.length === 1 && effectiveFormats[0] === 'screenshot';
const isImageOutput = options.output && /\.(png|jpg|jpeg|webp)$/i.test(options.output);
if (isScreenshotOnly && isImageOutput && result.success && result.data?.screenshot) {
const response = await fetch(result.data.screenshot);
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync(options.output, buffer);
return;
}
Environment
- firecrawl-cli 1.10.0
- Windows 11 / Node.js
- Dominant language
- TypeScript
- Stars
- 635
- Forks
- 106
- Avg merge
- 4h 52m
- Merged PRs (30d)
- 43
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firecrawl/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
firecrawl/cli#181 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
firecrawl-monitor skill: description exceeds Claude Code's 1024-char limit, skill fails to loadOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
firecrawl/cli#160 · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
ADD openalgoOpentemplate
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
vercel/ai#21528 · 3 comments ·
Maintainers usually reply within 1 day
-
bug Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
microsoft/fluentui-contrib#671 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sveltejs/acorn-typescript#150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100