Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Utilities
  • PyFlink DataStream
  • PyFlink Common

pyflink.multimodal.operators.image_crop#

image_crop(*columns, crop_coords=None, crop_type='center', crop_ratio=(0.8, 0.8), crop_size=None, concurrency=None)[source]#

Crop an image by coordinates, center ratio, or center size.

Parameters
  • *columns – Optional image columns. When provided, the UDF is applied directly instead of returning a factory.

  • crop_coords – Absolute pixel box (x1, y1, x2, y2). When provided, crop_type is set to "coordinate" automatically. Regions outside the input image are padded with zero-valued pixels.

  • crop_type – Crop strategy — "center" (default), "ratio", or "coordinate". "center" crops crop_size pixels from the center (falls back to crop_ratio if crop_size is None). "ratio" center-crops by crop_ratio. "coordinate" uses the absolute box from crop_coords.

  • crop_ratio – Fraction of width and height to keep, as (width_ratio, height_ratio). Values in (0, 1]. Default (0.8, 0.8).

  • crop_size – Fixed center-crop output size (width, height) in pixels. Only used when crop_type="center". None (default) falls back to crop_ratio.

  • concurrency – UDF concurrency. None uses the framework default.

Returns

A UDF producing decoded image values.

Example::
>>> # As a reusable variable
>>> crop = image_crop(crop_coords=(100, 100, 500, 500))
>>> df = df.with_columns("cropped", crop(col("img")))
>>>
>>> # Inline
>>> df = df.with_columns(
...     "cropped", image_crop(col("img"), crop_coords=(100, 100, 500, 500))
... )

previous

pyflink.multimodal.operators.image_rescale

next

pyflink.multimodal.operators.image_crop_black_border

Show Source

Created using Sphinx 4.5.0.