Functions Index :: R :: ResizeToFit

[<< up one level]

Module:

filters :: resize

Definition:

ResizeToFit(clip c, int target_w, int target_h, int "mode", string "resizer", val "rsz_param1", val "rsz_param2", bool "interlaced")

Description:

Resizes clip c such that it fits inside the rectangle specified by width target_w and height target_height.

There are three possible resize modes (zoom, crop, stretch) that are selected by using proper values for the mode argument (one of the constants RTF_ZOOM, RTF_CROP, RTF_STRETCH defined at the filters::resize module).

Default mode is zoom (the clip is zoomed so that it fits in at least one of its dimensions to the target rectangle). This mode may make the result to have black borders (either horizontal or vertical). Aspect ratio is retained.

In crop mode the clip completely covers the target rectangle possibly leaving out some parts by cropping. Aspect ratio is retained.

In stretch mode the clip may change aspect ratio since then it is forced to fit the target rectangle in both dimensions.

Arguments:

c: The clip to be resized.

target_w: The target width to resize the clip. If it is zero, then the clip's width will remain unaltered.

target_h: The target height to resize the clip. If it is zero, then the clip's height will remain unaltered.

mode (optional): Controls the way that clip c will be resized to fit the target dimensions (see above).

resizer, rsz_param1, rsz_param2, interlaced (optional): Have the same function as the Resize() filter.

Notes and conditions on arguments relations:

1] If target_w, target_h do not have a value appropriate for the clip's colorspace the filter will throw an error.

2] In both zoom and crop modes the clip is centered to the target rectangle. Thus two black bars will appear (zoom mode) and two slices will be croped out (crop mode) in either side of the specific clip dimension chosen by the filter.

3] The filter uses internally the Resize filter in order to execute clip resizing when needed. To control which specific Avisynth resizer will be used by the filter place a call to SetDefaultResizer with appropriate parameters before calling the filter.

Examples:

clp = AVISource(...)

# zoom to fit inside a 360x240 rectangle; use Lanczos4Resize c1 = clp.ResizeToFit(360, 240, resizer="lanczos4")

# from now on use Spline36Resize old = SetDefaultResizer("spline36")

# crop to fit inside a 360x240 rectangle c2 = clp.ResizeToFit(360, 240, RTF_CROP)

# stretch to fit inside a 360x240 rectangle c3 = clp.ResizeToFit(360, 240, RTF_STRETCH)

# stack results Stack(ArrayCreate(c1, c2, c3), 2, 2)

 

[<< top]