schickling/chromeless

Set deviceScaleFactor doesn't work

Open

Aperta il 22 dic 2017

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)TypeScript (13.240 star) (606 fork)batch import
enhancementgood first issuehelp wanted

Descrizione

I'm trying to get retina display screenshots using deviceScaleFactorwithout luck so far.

I have an AWS lambda as describing it here, basically using the remote functionality, something like this:

async function run() {
  let chromeless;
  try {
    chromeless = new Chromeless({
      remote: {
        endpointUrl: 'https://xxxxxxx.execute-api.us-west-2.amazonaws.com/dev/',
        apiKey: 'xxxxxxxxxxxxxxxxxxxx'
      },
      viewport: {
        width: 1280,
        height: 5000,
        scale: 2,
        deviceScaleFactor: 2,
      }
    })

    const screenshot = chromeless
      .setViewport({ deviceScaleFactor: 2 })
      .goto(options.url)
      .wait(5000)

    let fullPage = await screenshot.screenshot()

    const response = [{ id: 'Full page', url: fullPage }]
    for (let selector of options.selectors) {
      let url = await screenshot.wait(selector.selector).screenshot(selector.selector)
      selector.url = url
      response.push(selector);
    }

    console.log(JSON.stringify(response))
  } catch(err) {
    console.error(err)
  } finally {
    await chromeless.end()
  }
}

run().catch(console.error.bind(console))

On the above script, I tried to set the option for the remote server and set it in the viewport, none of them have any change in the output, so, going further I looked into the source code for the right option but I found it is hardcoded to 1 here.

so I'm wondering if is it possible to get screenshots with high DPI from chromeless?

Thank you

Guida contributor