feat(screenshot): add webp output format#41152
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| try { | ||
| const quality = format === 'jpeg' ? options.quality ?? 80 : undefined; | ||
| const quality = format === 'jpeg' ? options.quality ?? 80 : format === 'webp' ? options.quality : undefined; |
There was a problem hiding this comment.
No default quality for webp?
|
WebP on macOS WebKit is skipped. The WebKit protocol patch ( Verified with this Swift script on macOS 26.5: import CoreServices
import ImageIO
import UniformTypeIdentifiers
if let types = CGImageDestinationCopyTypeIdentifiers() as? [String] {
print("Image destination UTIs:")
for t in types where t.lowercased().contains("webp") || t.lowercased().contains("jpeg") || t.lowercased().contains("png") {
print(" \(t)")
}
}Output: No |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Adds `webp` to the screenshot type union for `page.screenshot()`, `locator.screenshot()`, the MCP `browser_take_screenshot` tool, and the playwright-cli `screenshot` command. Encoded natively by each browser — CDP for Chromium, `Page.screenshot` for Firefox, and `Page.snapshotRect` (with format + quality) for WebKit; the WebKit path also drops the PNG→JPEG re-encode round-trip in Node. The MCP/CLI tools infer the format from the filename extension when `type` is unset. The CLI help generator now lists enum choices for any `z.enum` option. WebP screenshots are not supported in WebKit on macOS because CoreGraphics does not ship a webp encoder UTI; the WebKit delegate throws a clear error there. Fixes microsoft/playwright-mcp#1632
3871415 to
e061865
Compare
Test results for "MCP"7290 passed, 1121 skipped Merge workflow run. |
Test results for "tests 1"2 flaky39525 passed, 775 skipped Merge workflow run. |
Summary
webptopage.screenshot()/locator.screenshot()type union. Encoded natively via CDP (Chromium),Page.screenshot(Firefox), andPage.snapshotRectwith format+quality (WebKit, which also drops the PNG→JPEG re-encode round-trip in Node).webpto the MCPbrowser_take_screenshottool.Fixes microsoft/playwright-mcp#1632