cropToBoundingBox

emlib.img.cropToBoundingBox(inputpath, outpath='', margin=0)[source]

Crop an image to its content, trimming any empty space

Parameters:
  • inputpath (str) – the path of the input image

  • outpath (str) – the path of the output. If not given the original image is modified

  • margin (Union[int, tuple[int, int, int, int]]) – a margin in pixels. Can also be a tuple (x0, y0, x1, y1)

Return type:

str | None