Overview
Sources
Libraries
Images API

Device Pixel Ratio dpr

Specify the device pixel ratio. Device pixel ratio is the ratio between the physical and logical pixels in the device.

A device pixel ratio of 2 will result in doubling the pixels of the image. If we specify width=300&dpr=2 as params we will get an image with a width of 600 pixels.

This parameter is useful to adapt images to devices with different screen pixel density (i.e. Apple Retina display).

Values

This parameter accepts integer values in the range 1 to 8.

  • 1: Minimum device pixel ratio.
  • 8: Maximum device pixel ratio.

The default value of this parameter is 1.

Examples

Specify a width of 400 pixels and a device pixel ratio of 2 with the params width=400 and dpr=2 will result in an image with 800 pixels width:

GET
https://assets.imglab-cdn.net/woman.jpeg?width=400&dpr=2
Woman holding a camera with a device pixel ratio of 2 using dpr parameter.
x px