Why not just figure out the pixelRatio once and then serve images according to that?
See this gist: https://gist.github.com/3848834
See this gist: https://gist.github.com/3848834
And an OLPC-style device might have different ratios if you're browsing using the e-ink display rather than the lcd.