Whenever an image URL is supplied in an API response, it will have a format similar to:
If this URL is served direct to the user, the original image will be displayed. However, various parameters can be added to the URL, to specify re-sizing and cropping of the image. The actual modification of the image will be done by Travelfusion before serving the image and will therefore minimise the download size for the client.
For example, to change the above image to width 100 and height 50, the URL would need to be adjusted to:
If it is required to scale the image to a width 100 and height 50, maintaining the aspect ratio, the URL would need to be adjusted to:
x(optional): the width desired
y(optional): the height desired
If x and/ or y are specified, without an 'action', Travelfusion will resize the image to the specified dimension(s) using a default (best) method.
resize_crop: Resizes (keeping aspect ratio) and THEN crops (i.e. changing aspect ratio) to the specified width/height. This requires both x and y dimensions.
resize: Resizes (keeping aspect ratio), but does not crop. (The image is resized such that 1 dimension is equal to the specified value, and the other dimension is within the specified value)
resize_noratio: Resizes the width and height independently to the requested size. Aspect ratio is therefore not retained.
Resize Crop (Default, Best Option)
Resize (Keeping Aspect Ratio)
Resize (Without keeping aspect ratio)