Bitmap Vector Conversion

BMP_Vector

class obi.macros.bmp2vector.BitmapVectorPattern(path)[source]

Converts an image to an array of vector points (as VectorPixelCommand). For high resolution images, this process can be quite resource intensive. This class uses multiprocessing.Pool to speed up conversion by executing multiple threads.

im[source]

See https://pillow.readthedocs.io/en/stable/reference/Image.html

Type:

PIL.Image

processed_im[source]

Populated by rescale()

Type:

PIL.Image | None

pattern_seq[source]

Populated by vector_convert()

Type:

bytearray | None

Parameters:

path – Path to a PIL-compatible image file

rescale(resolution, max_dwell, invert)[source]

Rescale the image to specified resolution, upsampling or downsampling as necessary. Rescale dwell times such that the brightest pixel has dwell time max_dwell.

Important

By default, white pixels (brightness 255) correspond to the maximum dwell time, and black pixels (brightness 0) correspond to no dwell time and will be skipped.

Parameters:
  • resolution (u16) – Resolution to scale pattern to.

  • (Dwe (max_dwell) – Maximum dwell value

  • invert (bool) – Invert grayscale levels

  • max_dwell (DwellTime)

vector_convert(progress_fn=lambda p: ...)[source]
Parameters:

progress_fn (function, optional) – Function that accepts a value from 0 to 100 and emits a progress indicator. Defaults to lambda p:print(p).