Documentation

Images.weserv.nl is an image cache & resize proxy. Our servers resize your image, cache it worldwide, and display it. Feedback? GitHub!

Requesting an image:

Quick reference

Name GET Description  
Width w Sets the width of the image, in pixels. info
Height h Sets the height of the image, in pixels. info
Device pixel ratio dpr Sets the output density of the image. info
Orientation or Rotates the image. info
Transformation t Sets how the image is fitted to its target dimensions. info
Crop crop Crops the image to specific dimensions. info
Crop alignment a Sets how the crop is aligned. info
Shape shape Crops the image to a specific shape. info
Brightness bri Adjusts the image brightness. info
Contrast con Adjusts the image contrast. info
Gamma gam Adjusts the image gamma. info
Sharpen sharp Sharpen the image. info
Trim trim Trim "boring" pixels from all edges. info
Blur blur Adds a blur effect to the image. info
Filter filt Applies a filter effect to the image. info
Background bg Sets the background color of the image. info
Quality q Defines the quality of the image. info
Output output Encodes the image to a specific format. info
Interlace / progressive il Adds interlacing to GIF and PNG. JPEG's become progressive. info
Base64 (data URL) encoding Encodes the image to be used directly in the src= of the <img>-tag. info
Default image errorredirect Redirects to a default image when there is a problem loading an image. info
Page page To load a given page. info

Size

Width

&w=

Sets the width of the image, in pixels.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300">

Height

&h=

Sets the height of the image, in pixels.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&h=300">

Device pixel ratio

&dpr=New!

The device pixel ratio is used to easily convert between CSS pixels and device pixels. This makes it possible to display images at the correct pixel density on a variety of devices such as Apple devices with Retina Displays and Android devices. You must specify either a width, a height, or both for this parameter to work. Use values between 1 and 8.

More info: Issue #115 - DPI support.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&h=144&dpr=2">

Orientation

&or=New!

Rotates the image. Accepts auto, 0, 90, 180 or 270. Default is auto. The auto option uses Exif data to automatically orient images correctly.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&h=300&or=90">

Transformation

&t=

Sets how the image is fitted to its target dimensions. Below are a couple of examples.

Fit

&t=fit

Default. Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio. Will not oversample the image if the requested size is larger than that of the original.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=fit">

Fitup

&t=fitup

Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio. Will increase the size of the image if it is smaller than the output size.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=fitup">

Square

&t=square

Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. Will increase the size of the image if it is smaller than the output size.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=square">

Squaredown

&t=squaredown

Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. Will not oversample the image if the requested size is larger than that of the original.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=squaredown">

Absolute

&t=absolute

Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=absolute">

Letterbox

&t=letterboxNew!

Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.

More info: Issue #80 - letterbox images that need to fit.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=letterbox&bg=black">

Crop position

&a=

You can also set where the image is cropped by adding a crop position. Only works when t=square. Accepts top, left, center, right or bottom. Default is center. For more information, please see the suggestion on our GitHub issue tracker: Issue #24 - Aligning.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=square&a=top">

Crop Focal Point

&a=crop-x%-y%New!

In addition to the crop position, you can be more specific about the exact crop position using a focal point. Only works when t=square. This is defined using two offset percentages: crop-x%-y%.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=square&a=crop-0-20">

Smart crop

&a=entropy or &a=attentionNew!

Crops the image down to specific dimensions by removing boring parts. Only works when t=square. More info: Issue #90 - Add support for smart crop.

Accepts:

  • entropy: focus on the region with the highest Shannon entropy.
  • attention: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.
<img src="//images.weserv.nl/?url=ory.weserv.nl/zebra.jpg&w=300&h=300&t=square&a=attention">

Manual crop

&crop=

Crops the image to specific dimensions after any other resize operations. Required format: width,height,x,y.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&crop=300,300,680,500">

Shape

&shape=

Crops the image to a specific shape. Use &strim to also remove the remaining whitespace. More info: Issue #49 - Add circle effect to photos.

Note

Previously the &strim parameter was enabled by default. In December 2017 it was changed to an optional parameter to be more consistent with other features.

Accepts:

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&h=300&t=square&shape=circle">

Adjustments

Brightness

&bri=New!

Adjusts the image brightness. Use values between -100 and +100, where 0 represents no change.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&bri=-25">

Contrast

&con=New!

Adjusts the image contrast. Use values between -100 and +100, where 0 represents no change.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&con=25">

Gamma

&gam=New!

Adjusts the image gamma. Use values between 1 and 3. The default value is 2.2, a suitable approximation for sRGB images.

Note

The behavior of adjusting the image gamma was changed in December 2017. We apologize for any inconvenience caused.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&gam=3">

Sharpen

&sharp=New!

Sharpen the image. Required format: f,j,r

Arguments:

  • Flat f - Sharpening to apply to flat areas. (Default: 1.0)
  • Jagged j - Sharpening to apply to jagged areas. (Default: 2.0)
  • Radius r - Sharpening mask to apply in pixels, but comes at a performance cost. (optional)
<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&sharp=5,5,3">

Trim

&trim=

Trim "boring" pixels from all edges that contain values within a similarity of the top-left pixel. Trimming occurs before any resize operation. Use values between 1 and 254 to define a tolerance level to trim away similar color values. You also can specify just &trim, which defaults to a tolerance level of 10.

More info: Issue #39 - able to remove black/white whitespace.

<img src="//images.weserv.nl/?url=ory.weserv.nl/transparency_demo.png&w=300&trim=10">

Background

&bg=New!

Sets the background color of the image. Supports a variety of color formats. In addition to the 140 color names supported by all modern browsers (listed here), it also accepts hexadecimal RGB and RBG alpha formats. More info: Issue #81 - Background setting.

Hexadecimal

  • 3 digit RGB: CCC
  • 4 digit ARGB (alpha): 5CCC
  • 6 digit RGB: CCCCCC
  • 8 digit ARGB (alpha): 55CCCCCC
<img src="//images.weserv.nl/?url=ory.weserv.nl/transparency_demo.png&w=400&bg=black">

Effects

Blur

&blur=New!

Adds a blur effect to the image. Use values between 0 and 100.

More info: Issue #69 - Allow blur transformation (with radius parameter).

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&blur=5">

Filter

&filt=New!

Applies a filter effect to the image. Accepts greyscale, sepia or negate.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&filt=greyscale">

Encoding

Quality

&q=

Defines the quality of the image. Use values between 0 and 100. Defaults to 85. Only relevant if the format is set to jpg.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&q=20">

Output

&output=

Encodes the image to a specific format. Accepts jpg, png, gif, tiff or webp. If none is given, it will honor the origin image format.

More info: Issue #62 - Format conversion.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&output=webp">

Interlace / progressive

&il

Adds interlacing to GIF and PNG. JPEG's become progressive.

More info: Issue #50 - Add parameter to use progressive JPEGs.

<img src="//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&w=300&il">

Base64 (data URL)

&encoding=base64

Encodes the image to be used directly in the src= of the <img>-tag. Use this link to see the output result.

More info: Issue #59 - Return image base64 encoded.

//images.weserv.nl/?url=ory.weserv.nl/lichtenstein.jpg&crop=100,100,680,500&encoding=base64

Miscellaneous

Default image

&errorredirect=New!

If there is a problem loading an image, then a error is shown. However, there might be a need where instead of giving a broken image to the user, you want a default image to be delivered.

More info: Issue #37 - Return default image if the image's URL not found.

The URL must not include a errorredirect querystring (if it does, it will be ignored).

<img src="//images.weserv.nl/?url=example.org/noimage.jpg&errorredirect=ssl:images.weserv.nl%2F%3Furl%3Dory.weserv.nl/lichtenstein.jpg%26w%3D300">

Page

&page=New!

To load a given page (for an PDF, TIFF and multi-size ICO file). The value is numbered from zero.