You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Save screenshots using webp format #22984
WebP is a modern image format that provides superior lossless and lossy compression for images on the web.
WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.
Would be great to have this feature. I am currently using sharp to compress the screenshot to WebP: sharp(screenshot).webp() but having it natively would be much better and reduce the execution time (would avoid having to perform a webp compression on a jpg/png image).
We would really love to be able to take WebP format screenshots in our system, for the reduced file size. For a smaller CPU/memory hit, ideally the WebP could be generated by the browser as the screenshot it taken instead of us having to convert a PNG in application code.
I tried looking into where in the code the formats are applied when screenshotting, and it seems here (via search results)…
Interestingly, the Playwright approach for Webkit is to screenshot a PNG (is that the only format Webkit supports?) and then after (if JPEG is requested in options) convert the format to a JPEG. This means people selecting JPEG thinking they can be more efficient would be unaware it might double? the hardware used to generate their screenshot. If Playwright is already happy with the approach of converting PNG screenshots on the fly to other formats, then there is no limit to doing so for WebP for all the browsers that don't support WebP screenshots natively, and remove the conversion process once they do in the future.
I couldn't find docs for the Firefox dev tools protocol. It seems that Firefox is not able to take a WebP screenshot, but I'm not sure if this is just a UI limitation or an underlying limitation on how Firefox screenshots under the hood. Chat GPT seems confident Firefox can't screenshot WebP, and this Bugzilla issue doesn't inspire confidence:
Activity
guillaume-acard commentedon Feb 15, 2024
Would be great to have this feature. I am currently using sharp to compress the screenshot to WebP:
sharp(screenshot).webp()but having it natively would be much better and reduce the execution time (would avoid having to perform a webp compression on a jpg/png image).jaydenseric commentedon Apr 9, 2024
We would really love to be able to take WebP format screenshots in our system, for the reduced file size. For a smaller CPU/memory hit, ideally the WebP could be generated by the browser as the screenshot it taken instead of us having to convert a PNG in application code.
I tried looking into where in the code the formats are applied when screenshotting, and it seems here (via search results)…
Chromium:
playwright/packages/playwright-core/src/server/chromium/crPage.ts
Line 298 in 62ae71f
Chromium is capable of taking WebP screenshots:
https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshot
So no blocker there.
Webkit:
playwright/packages/playwright-core/src/server/webkit/wkPage.ts
Lines 856 to 860 in 62ae71f
Interestingly, the Playwright approach for Webkit is to screenshot a PNG (is that the only format Webkit supports?) and then after (if JPEG is requested in options) convert the format to a JPEG. This means people selecting JPEG thinking they can be more efficient would be unaware it might double? the hardware used to generate their screenshot. If Playwright is already happy with the approach of converting PNG screenshots on the fly to other formats, then there is no limit to doing so for WebP for all the browsers that don't support WebP screenshots natively, and remove the conversion process once they do in the future.
Firefox:
playwright/packages/playwright-core/src/server/firefox/ffPage.ts
Lines 438 to 443 in 62ae71f
I couldn't find docs for the Firefox dev tools protocol. It seems that Firefox is not able to take a WebP screenshot, but I'm not sure if this is just a UI limitation or an underlying limitation on how Firefox screenshots under the hood. Chat GPT seems confident Firefox can't screenshot WebP, and this Bugzilla issue doesn't inspire confidence:
https://bugzilla.mozilla.org/show_bug.cgi?id=1742565
WebP support might need to be added to Firefox to avoid Playwright having to do a format conversion after taking the screenshot.
erickguan commentedon Nov 20, 2024
I tried WebP screenshot from Chrome by:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --screenshot=/tmp/screen.webp https://google.comIt seems that Chrome generates a lossy webp screenshot while PNG is lossless. I am not sure how lossy format will impact the pixel matcher use case.
dlecan commentedon Oct 20, 2025
What would be the specs for each browser family?
kristaps-aksjonovs commentedon Apr 9, 2026
Are the any idea to implement this?
Because webp could save a lot of storage for bigger projects.
yury-s commentedon Jul 14, 2026
Will be released in 1.62