Turn 2D vector paths into raster images using pillow

trimesh.path.raster.rasterize(path, pitch=None, origin=None, resolution=None, fill=True, width=None)

Rasterize a Path2D object into a boolean image (“mode 1”).

  • path (Path2D) – Original geometry

  • pitch (float or (2,) float) – Length(s) in model space of pixel edges

  • origin ((2,) float) – Origin position in model space

  • resolution ((2,) int) – Resolution in pixel space

  • fill (bool) – If True will return closed regions as filled

  • width (int) – If not None will draw outline this wide in pixels


raster – Rasterized version of input as mode 1 image

Return type: