Skip to content

How to work with the Media service

Our Media Service provides the images in the appropriate sizes. This article describes the pain and a modern solution for html clients: Responsive images

Thumbnail creation

We are using AI to resize and crop the pictures if the requested size is smaller than 1024 pixels. The service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. If the requested image is larger than 4 MB or if the requested size is larger than 1024 pixels then a simple resizing and cropping algorithm is used.

Service is taking the identifier of an ImageObject in our Infocenter and processes its content image.

https://media.discover.swiss/image/GDL_402736821?height=34&width=567
https://media.discover.swiss/image/{identitifier}?width={w}&height={h}

Parameter Description
identifier Identifier of the image-object
width Width of the thumbnail, in pixels.
height Height of the thumbnail, in pixels.

The image references in all Infocenter objects is extended by the basic thumbnail url:

{
    "thumbnailUrl": "https://media.discover.swiss/image/TSVM-OUA_24211673",
    "contentUrl": "http://img.oastatic.com/img/24211673/.jpg",
    "@id": "http://api.discover.swiss/info/v1/imageObjects/TSVM-OUA_24211673",
    "identifier": "TSVM-OUA_24211673"
}

Features

  • If both width and height are missing or less than 0, the picture is returned in original size.
  • If one of parameter is bigger than original, this parameter is set to original. The ratio is kept.
  • If only one is missing the ratio is kept.
  • If any exception occurs the picture is returned in original size.
  • If the ImageObject or the in contentUrl referenced image doesn't exists "404 Not found" will be returned.

Sample app

You can check the feature in our sample app as well: demo.discover.swiss


Last update: July 22, 2020 11:30:33