Prepr Documentation

Prepr Documentation

Welcome to the Prepr Documentation. You'll find comprehensive guides and documentation to help you start working with Prepr as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Resizing images with CloudFront

Introduction

The Images API is a read-only API for delivering images to apps, websites and other media outlets.

The Images API is available via a globally (by default Europe/US/Canada) distributed content delivery network (CDN) powered by Amazon CloudFront services. The server closest to the user serves all content, which minimizes latency and especially benefits mobile apps. Hosting content in multiple global data centers also improves the availability of content.

You can request images in in specific sizes and formats, and crops.

Images are returned with a source_file field. This object returns a cdn_url param that you can use as a basis for resizing the image needed for your app.

The url contains a part that is returned as {format} you need to replace this with the desired format.
Options are width (w), height (h), quality (q) and crop (c).

Crop options: (default: centre)
north, northeast, east, southeast, south, southwest, west, northwest, center, centre

The format is constructed as {option}_{value} so if we would wanted to get the image in a 200px width form, {format} would be replaced with w_200.

To simplify this it is possible to let the API construct those urls for you. Just add them as an extra field in the source_file field. For example:

?fields=source_file{resized{landing.width(232).h(232),thumb.width(123).h(123)}}

"source_file": {
  "id": "0e10b16-a403-41c1-bb2d-b13b1715585",
  "created_on": "2018-04-17T19:45:53+00:00",
  "changed_on": null,
  "label": "SourceFile",
  "original_name": "74658732548727647823678.jpg",
  "mime_type": "image/jpeg",
  "file_size": 10157,
  "file": "https://s3.eu-central-1.amazonaws.com/example/0e1a0b16-a403-41c1",
  "cdn_url": "https://d3irvg41fk9jwi.cloudfront.net/{format}/example/0e10b16-a403-41c1-bb2d-b13b1715585.jpg",
  "resized": {
    "landing": "https://d3irvg41fk9jwi.cloudfront.net/w_232,h_232/example/0e10b16-a403-41c1-bb2d-b13b1715585.jpg"
  }
}

This will add an extra param to the object with the pre-rendered url. It is possible to add up to 3 different formats into the request.