Also known as
  • Add other possible names for this topic
Name   image_thumb
Description   Thumbnails an image to the requested size
Accessible Via   /api/trans/image_thumb/<id of image content>
HTTP GET   Yes
HTTP POST   No
Special Headers   None
Login Required   No
Required Arguments   maxwidth: maximum allowable width of the generated thumbnail

maxheight: maximum allowable height of the generated thumbnail
mode: one of 'fit', 'fill', 'fillcrop', defaults to 'fit'. See notes below for details.

Optional Arguments   onfail: uses URL provided as argument to redirect to in case of thumbnailing failure.
Extra Arguments Ignored   No
Response Format   Depends on the mime-type of the original image
Notes   Supported image formats: PNG, JPG, and GIF.

The thumb-nailing service will only process images whose original size is less than 36m pixels. image_thumb is not meant to be a workaround for the raw service.

Rules

  1. If no parameters are provided the parameters default to 75x75 in fit mode.
  2. If maxheight=0 and maxwidth=0 then the original image is returned.
  3. If maxheight=0 or maxwidth=0, and the other set to a legitimate value, the 0 value is discarded and the image is scaled such that the returned dimension matches the specified dimension.
  4. If the desired dimensions are greater than the original image, the original image will be returned.
  5. Zooms are NOT allowed. Apparent zoom requests may be accepted in the following example situation only for fillcrop mode:
    If the original image is 50x300 and the desired dimensions are 64x64 the service will return 50x64 cropped image.

MODES of operation:
The thumbnailing service operates in three modes:

  1. fit: In fit mode, given a rectangle, the image will be resized to fit in the rectangle. There may be empty space left over along one dimension. Scaling is done using the smaller scale value, i.e. the smaller of dw/w and dh/h is used to scale both dimensions.
  2. fill: In fill mode, given a rectangle, the image will be resized so that the rectangle fits completely inside the resulting image and one of the image dimensions is the same as one of the provided rectangle's. Scaling is done using the larger scale value i.e. the larger of dw/w and dh/h is used to scale both dimensions. The practical outcome is that the dimension (of the provided rectangle) nearest to the actual dimension will be resized to be exactly the matching rectangle dimension.
    The following modes REQUIRE that the user provide both the dimensions of the desired rectangle.
  3. fillcrop: In this mode, a fill operation is done and any part of the image that protrudes out of the provided rectangle is cropped out.

There are two levels of failover for this service now:

  1. If thumb-nailing fails because image is too large and the onfail argument is provided, service redirects to URL provided.
  2. If no onfail argument is provided, it will thumbnail a default image and send that back.
  3. If default image is not found, returns a 413 (sec. 10.4.14)
For additional information on using the callback parameter to generate a JSONP response, or using onsucceed and onfail to redirect to a URI template, see Common API Query Parameters.

Examples:

A. Wide Image

1. Original: 

http://www.freebase.com/api/trans/raw/guid/9202a8c04000641f800000000514e28e

2. Only maxwidth

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f800000000514e28e?maxwidth=100

3. maxwidth and maxheight

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f800000000514e28e?maxwidth=100&maxheight=100

4. No arguments

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f800000000514e28e

 B. Tall Image

 1. Original

http://www.freebase.com/api/trans/raw/guid/9202a8c04000641f8000000004972c6e

 2. Only maxwidth

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f8000000004972c6e?maxwidth=100

3. maxwidth and maxheight

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f8000000004972c6e?maxwidth=100&maxheight=100

4.  No arguments

http://www.freebase.com/api/trans/image_thumb/guid/9202a8c04000641f8000000004972c6e 

Status
Accessible via
  • /api/trans/image_thumb
Login required
  • No
Permits HTTP GET
  • Yes
Permits HTTP POST
  • No
Special headers
Extra arguments ignored
  • Yes
Response type
With the exception of Wikipedia summaries and some images the content on this page is typically distributed under the Creative Commons Attribution license or Public Domain.
Created by skud Dec 17, 2007
Last edited by philg Jul 30, 2008
View topic history »
Gallery add edit
There are no images for this topic yet.

Recent Discussions about api/trans/image_thumb

There are no conversations on this topic. Would you like to start one?

Start the Discussion »