Image helper

Module escpos.image

Image format handling class

This module contains the image format handler EscposImage.

author:Michael Billington
organization:python-escpos
copyright:Copyright (c) 2016 Michael Billington <michael.billington@gmail.com>
license:MIT
class escpos.image.EscposImage(img_source)[source]

Bases: object

Load images in, and output ESC/POS formats.

The class is designed to efficiently delegate image processing to PIL, rather than spend CPU cycles looping over pixels.

width

Width of image in pixels

width_bytes

Width of image if you use 8 pixels per byte and 0-pad at the end.

height

Height of image in pixels

to_column_format(high_density_vertical=True)[source]

Extract slices of an image as equal-sized blobs of column-format data.

Parameters:high_density_vertical – Printed line height in dots
to_raster_format()[source]

Convert image to raster-format binary

split(fragment_height)[source]

Split an image into multiple fragments after fragment_height pixels

Parameters:fragment_height – height of fragment
Returns:list of PIL objects
center(max_width)[source]

In-place image centering

Param:Maximum width in order to deduce x offset for centering
Returns:None