You are here: Web API Functions > getimage > fit

fit

Like the crop method, the fit method returns an image that is scaled to the natural level whose dimensions best match those of the requested bounding box. The fit method differs from the crop method in that whereas the crop method treats the bounding box as a suggestion and the natural level as a rigid requirement, the fit method treats the bounding box as the rigid requirement. The examples below demonstrate how different natural levels accommodate themselves to the dimensions of the bounding box.

Example: 400 x 400 bounding box request using fit method

Request:

http://demo.lizardtech.com/lizardtech/iserv/getimage?cat=Geo&item=BLM_relief.sid&wid=400&hei=400&method=fit

Result:

As in the first example using the crop method, the natural level most closely matching the requested 400 x 400 bounding box again measures 454 x 320. The image is both clipped (54 pixels total off of the width) and expanded (from 320 to 400 in height - note that since the selected region is the entire image, there is no more "scene" to show and so the added height is "filled in" with background).

To ensure that the entire requested region fits inside of the requested bounds, use the fitinside method.

Example: 300 x 300 bounding box request using fit method

Request:

http://demo.lizardtech.com/lizardtech/iserv/getimage?cat=Geo&item=BLM_relief.sid&wid=300&hei=300&method=fit

Result:

In this second example, the natural level closest to the requested 300 x 300 bounding box measures 227 x 160. This results in the entire requested region being satisfied and expanded to fill the rest of the bounding box.