Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Added devicePixelRatio support (fixes #10964) #12839

Closed
wants to merge 1 commit into from

Conversation

vegetableman
Copy link

fixes #10964

Example:-

var webPage = require('webpage');
var page = webPage.create();

// An example url that supports @2x background-image with the following css:-
/* body {
     background-image: background-image: url('http://retinajs.s3.amazonaws.com/images/backgrounds/bg.jpg');
  }
  @media all and (-webkit-min-device-pixel-ratio: 1.5) {
     body {
       background-image: background-image: url('http://retinajs.s3.amazonaws.com/images/backgrounds/bg@2x.jpg');
    }
} */
var examplePage = 'http://imulus.github.io/retinajs/';

//Pass a dpr of your choosing
page.devicePixelRatio = 1.5; // in this case, >=1.5 to get the retina-supporting bg-image

page.open(examplePage, function() {
   var backgroundImage = page.evaluate(function() {
     return window.getComputedStyle(document.body).backgroundImage;
   });
   console.log(backgroundImage); // returns http://retinajs.s3.amazonaws.com/images/backgrounds/bg@2x.jpg
   page.render('2x.png');
});

@Aeon
Copy link

Aeon commented Dec 19, 2014

+1

@vitallium vitallium force-pushed the master branch 2 times, most recently from b3cd914 to c4df640 Compare June 27, 2015 08:43
@KuroGuo
Copy link

KuroGuo commented Jul 1, 2015

+1

@vitallium
Copy link
Collaborator

Please send Webkit-specific changes to our submodule repo. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

set window.devicePixelRatio for 'retina' screenshots
4 participants