New issue
Advanced search Search tips

Issue 770743 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 755095
Owner: ----
Closed: Oct 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Headless chrome renders screenshot using 2x resolution with retina display

Reported by v04...@gmail.com, Oct 2 2017

Issue description

Chrome Version       : 61.0.3163.100 (Official Build) (64-bit)

What steps will reproduce the problem?
(1) create the following SVG-file (circle.svg):

<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
  <circle fill='red' cx='50' cy='50' r='50'/>
</svg>

(2) Capture a screenshot using headless mode, expecting a png with a specified dimensions:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --screenshot --window-size=256,256 file://$PWD/circle.svg

(3) Check screenshot.png

What is the expected result?

screenshot.png should be of size 256x256, as requested

What happens instead?

screenshot.png is of a double size 512x512

OS: macOS Sierra 10.12.6 (16G29), MacBook Pro (Retina, Mid 2012)

This isn't about SVG, any screenshot will be the same, I'm using SVG as an example. If I'm connecting second display and close a laptop lid, so the only display is non-retina display, Chrome renders screenshot with correct size. I don't think that headless behaviour should depend on a currently active display. The only workaround is to check for presence of Retina display using
/usr/sbin/system_profiler SPDisplaysDataType | grep 'Resolution.*Retina'
and request a chrome a half-size image, but it doesn't work if I need a image with odd size.
 
circle.svg
116 bytes Download
screenshot.png
12.2 KB View Download
I think you can use the `--force-device-scale-factor=1` flag to not depend on the active display.
Labels: Needs-Triage-M61
Labels: Proj-Headless
Mergedinto: 755095
Status: Duplicate (was: Unconfirmed)
This is a known limitation of Headless on Mac.
I'm merging this issue with crbug/755095.

In your case forcing the scale factor as einbinder@ suggested in #1 should work.



Comment 5 by v04...@gmail.com, Oct 11 2017

Yes, it works, thanks for suggestion. Might be surprising for new users.

Sign in to add a comment