fffw package

Module contents

class fffw.scaler.Scaler(source_size: Tuple[int, int], par: float = 1.0, rotation: int = 0, accuracy: int = 2)

Bases: object

Image and video dimensions transformation helpers.

crop(left: int, top: int, width: int, height: int) Scaler

Returns new scaler with cut dimensions.

rotate(rotation: int = 90) Scaler

Retuns new scaler with 90-degree rotation.

scale(scale: float) Scaler

Scales source image with a scale.

scaled dimension is source dimension multiplied by scale.

scale_crop(target_size: Tuple[int, int]) Tuple[Scaler, Tuple[int, int, int, int]]

Scales source image to target_size with cutting borders.

One of resulting dimensions is equal to corresponding target dimension, another was greated initially, but was cut to target dimension.

scale_fit(target_size: Tuple[int, int]) Scaler

Scales source image fitting it to target_size.

One or both of resulting dimensions is equal to corresponding target dimension, another is less.

property aspect: float
property pixel_size: Tuple[int, int]

Source image size in square pixels.

fffw.scaler.xround(val: float, div: int, how: None | str = None, quality: int = 5) int

Number rounding with steroids.

Parameters:
  • val – float, a number to round

  • div – int, accuracy. Resulting value will be dividable to this.

  • how – (None|’ceil’|’floor’), round mode None - classic rounding, up or down ceil - round up floor - round down

  • quality – number of digits after comma used to truncate numbers like 503.9999999999999994 before main rounding.