Skip to content

Commit aeab527

Browse files
committed
feat: change default screenshot format to png and update related documentation
1 parent d821d77 commit aeab527

File tree

6 files changed

+14
-149
lines changed

6 files changed

+14
-149
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,10 @@ The Chrome DevTools MCP server supports the following configuration option:
384384
- **Default:** `true`
385385

386386
- **`--screenshot-format`**
387-
Default image format for screenshots. Options: png, jpeg, webp. Default is jpeg.
387+
Default image format for screenshots. Options: png, jpeg, webp. Default is png.
388388
- **Type:** string
389389
- **Choices:** `png`, `jpeg`, `webp`
390-
- **Default:** `jpeg`
390+
- **Default:** `png`
391391

392392
<!-- END AUTO GENERATED OPTIONS -->
393393

@@ -432,7 +432,7 @@ To get the WebSocket endpoint from a running Chrome instance, visit `http://127.
432432

433433
### Configuring default screenshot format
434434

435-
You can set a default image format for all screenshots using the `--screenshot-format` option. The default is JPEG. You can change it to PNG or WebP if needed:
435+
You can set a default image format for all screenshots using the `--screenshot-format` option. The default is PNG. You can change it to JPEG or WebP if needed:
436436

437437
```json
438438
{
@@ -441,7 +441,7 @@ You can set a default image format for all screenshots using the `--screenshot-f
441441
"command": "npx",
442442
"args": [
443443
"chrome-devtools-mcp@latest",
444-
"--screenshot-format=png"
444+
"--screenshot-format=jpeg"
445445
]
446446
}
447447
}
@@ -451,7 +451,10 @@ You can set a default image format for all screenshots using the `--screenshot-f
451451
When configured, the `take_screenshot` tool will use this format by default unless explicitly overridden by passing a `format` parameter. Supported formats are `png`, `jpeg`, and `webp`.
452452

453453
> [!TIP]
454-
> JPEG is the default format as it typically produces smaller file sizes than PNG, which improves performance when working with screenshots. WebP offers the best compression while maintaining quality. Use PNG if you need lossless screenshots.
454+
> PNG is the default format as it provides lossless screenshots. JPEG typically produces smaller file sizes than PNG, which improves performance when working with screenshots. WebP offers the best compression while maintaining quality.
455+
456+
> [!NOTE]
457+
> **Claude Code users**: If you experience issues with screenshots not displaying correctly, explicitly pass `jpeg` as the format parameter in all `take_screenshot()` calls until the issue is resolved on Claude Code's side. For example: `take_screenshot(format="jpeg")`.
455458
456459
You can also run `npx chrome-devtools-mcp@latest --help` to see all available configuration options.
457460

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ export const cliOptions = {
163163
screenshotFormat: {
164164
type: 'string',
165165
describe:
166-
'Default image format for screenshots. Options: png, jpeg, webp. Default is jpeg.',
166+
'Default image format for screenshots. Options: png, jpeg, webp. Default is png.',
167167
choices: ['png', 'jpeg', 'webp'] as const,
168-
default: 'jpeg',
168+
default: 'png',
169169
},
170170
} satisfies Record<string, YargsOptions>;
171171

src/tools/screenshot.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import {zod} from '../third_party/index.js';
88
import type {ElementHandle, Page} from '../third_party/index.js';
99

10-
import {detectImageFormat} from '../utils/imageFormat.js';
1110
import {ToolCategory} from './categories.js';
1211
import {defineTool} from './ToolDefinition.js';
1312

@@ -87,23 +86,18 @@ export const screenshot = defineTool({
8786
);
8887
}
8988

90-
// Detect the actual format of the screenshot data
91-
// Puppeteer may not always return the requested format
92-
const actualFormat = detectImageFormat(screenshot);
93-
console.error(`[DEBUG] Requested format: ${format}, Detected format: ${actualFormat}`);
94-
9589
if (request.params.filePath) {
9690
const file = await context.saveFile(screenshot, request.params.filePath);
9791
response.appendResponseLine(`Saved screenshot to ${file.filename}.`);
9892
} else if (screenshot.length >= 2_000_000) {
9993
const {filename} = await context.saveTemporaryFile(
10094
screenshot,
101-
actualFormat,
95+
`image/${format}`,
10296
);
10397
response.appendResponseLine(`Saved screenshot to ${filename}.`);
10498
} else {
10599
response.attachImage({
106-
mimeType: actualFormat,
100+
mimeType: `image/${format}`,
107101
data: Buffer.from(screenshot).toString('base64'),
108102
});
109103
}

src/utils/imageFormat.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

tests/cli.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ describe('cli args parsing', () => {
1616
categoryPerformance: true,
1717
'category-network': true,
1818
categoryNetwork: true,
19-
'screenshot-format': 'jpeg',
20-
screenshotFormat: 'jpeg',
19+
'screenshot-format': 'png',
20+
screenshotFormat: 'png',
2121
};
2222

2323
it('parses with default args', async () => {

tests/utils/imageFormat.test.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)