schickling/chromeless

Set deviceScaleFactor doesn't work

Opened this issue · 2 comments

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

I'm having the same issue. Anyone else have a workaround to this - short of forking and hardcoding the change?

Thanks!

Would be grateful for a PR that un-hardcode's it. 😊