Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webp to screenshot options #7565

Merged
merged 5 commits into from Sep 21, 2021
Merged

Conversation

jonchurch
Copy link
Contributor

@jonchurch jonchurch commented Sep 13, 2021

closes: #5348

Not sure since when, but webp is an option in Page.captureScreenshot now.

All that is needed is to allow users to pass type: "webp" through.

After making said change to allow passing webp through as an option, this code successfully creates webp screenshots using either type: "webp" or using the .webp extension from the filepath.

const puppeteer = require('puppeteer')

async function run() {
const browser = await puppeteer.launch()
  const page = await browser.newPage()
  await page.setViewport({ width: 1280, height: 800 })
  await page.goto('https://www.nytimes.com/')
  await page.screenshot({ path: `${__dirname}/nytimes.webp`, fullPage: true, type: 'webp'})
  await page.screenshot({ path: `${__dirname}/nytimes_alt.webp`, fullPage: true,})
  await browser.close()
}

run().then(() => console.log('done')).catch(console.log)

Happy to take any help getting this mergeable, ie writing tests.

I'd upload a webp here but github doesn't support them!

@google-cla
Copy link

google-cla bot commented Sep 13, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Sep 13, 2021
@jonchurch
Copy link
Contributor Author

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 13, 2021
Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! The change looks good from a technical point of view but it would be great if you could also update the documentation (docs/api.md) and add a unit test (see screenshot.spec.ts). Thanks!

src/common/Page.ts Show resolved Hide resolved
src/common/Page.ts Show resolved Hide resolved
src/common/Page.ts Outdated Show resolved Hide resolved
@google-cla
Copy link

google-cla bot commented Sep 21, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Sep 21, 2021
@jschfflr
Copy link
Contributor

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 21, 2021
@jschfflr
Copy link
Contributor

@jonchurch I already went ahead and addressed the outstanding comments to get this into the next release :)

@jschfflr jschfflr enabled auto-merge (squash) September 21, 2021 14:12
@jschfflr jschfflr merged commit 43a9268 into puppeteer:main Sep 21, 2021
@jonchurch
Copy link
Contributor Author

@jschfflr Yay! Thank you for getting this over the finish line 🥇

@jschfflr
Copy link
Contributor

Sure, happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save Screenshots in WEBP Image Format
2 participants