schickling/chromeless

Set deviceScaleFactor doesn't work

Open

#367 创建于 2017年12月22日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)TypeScript (606 fork)batch import
enhancementgood first issuehelp wanted

仓库指标

Star
 (13,240 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南