Skip to content

Commit

Permalink
jpeg screenshot and capture beyond viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
lluisd committed Feb 20, 2024
1 parent c7368c7 commit f5fa248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions helpers/browserApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class PuppeteerApi {
async handleStart() {
await this.page.setViewport({ width: 1920, height: 1080 })
await this.page.goto("https://www.twitch.tv/" + config.twitch.channels, { waitUntil: ['networkidle0', 'domcontentloaded'] })

await this.removeElementsAndGetDiv()
}

Expand All @@ -46,7 +45,9 @@ class PuppeteerApi {
if (this.svgImage) {
return await this.svgImage.screenshot({
path: path,
omitBackground: true
type: "jpeg",
quality: 75,
captureBeyondViewport: true
})
}
return null
Expand Down
4 changes: 2 additions & 2 deletions services/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ async function getScreenshot() {
}
const name = Math.random().toString(36).substring(2,8)
try {
bufferImage = await browserApi.takeScreenshot(`public/images/${name}.png`)
bufferImage = await browserApi.takeScreenshot(`public/images/${name}.jpg`)
} catch (error) {
console.log(error)
return null
}
return {buffer: bufferImage, fileName: `${name}.png` }
return {buffer: bufferImage, fileName: `${name}.jpg` }
}

async function startAndWarmUpBrowserIfNeeded() {
Expand Down

0 comments on commit f5fa248

Please sign in to comment.