Skip to content

Instantly share code, notes, and snippets.

@cemjotform
Created January 22, 2018 02:21
Show Gist options
  • Save cemjotform/0d8d8b9916c25d25478585548bc93b9e to your computer and use it in GitHub Desktop.
Save cemjotform/0d8d8b9916c25d25478585548bc93b9e to your computer and use it in GitHub Desktop.
const puppeteer = require('puppeteer');
const getColors = require('get-image-colors');
(async() => {
try {
// Initialize browser and page
const browser = await puppeteer.launch({args: ['--no-sandbox']});
const page = await browser.newPage();
// Open required page and set viewport to process desktop view of website
await page.goto(url, {waitUntil: 'load'});
// Taking full page screenshot without background color
const fullpageSS = await page.screenshot({
fullPage: true,
omitBackground: true,
type: 'jpeg',
quality: 100
});
// Extracting color
const colors = await getColors(fullPageSS, 'image/jpeg');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment