Device pixel ratio

      Last updated May 18, 2020

    The dpr parameter adds the ability to serve correctly sized images for devices that expose a device pixel ratio. The device pixel ratio is the ratio between physical pixels and logical pixels. For instance, the iPhone 5 reports a device pixel ratio of 2, because the physical linear resolution is double the logical resolution.

    Other devices report different device pixel ratios, including non-integer ones. For example, the Nokia Lumia 1020 reports 1.6667, whereas the Samsung Galaxy S4 reports 3.

    API Pattern

    dpr={value}

    Parameter

    Parameter Description
    dpr Device Pixel Ratio.

    Parameter Values

    Value Description
    Integer A whole number between 1 and 10000.
    Float Decimal number between 0.0 and 9999.999…

    Examples

    Description HTML Demo
    Resize & Device Pixel Ratio - Resize the width to 200px for screens with a device pixel ratio of 2. <img src="image.jpg?width=200&dpr=2"/> Example
    Back to Top