| 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 - If no parameters are provided the parameters default to 75x75 in fit mode.
- If maxheight=0 and maxwidth=0 then the original image is returned.
- 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.
- If the desired dimensions are greater than the original image, the original image will be returned.
- 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: - 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.
- 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.
- 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: - If thumb-nailing fails because image is too large and the onfail argument is provided, service redirects to URL provided.
- If no onfail argument is provided, it will thumbnail a default image and send that back.
- 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