Creates Star graphics mode raster images for use with Star TSP series thermal printers
Project description
python-StarTSPImage
Print from Python to Star TSP100/143/650/654
Star TSP100/TSP143 printers do not have any font sets etc on board the printer, so any data being sent directly to the printer must first be converted into a raster image using the appropriate graphic mode commands. (Star do provide a driver that emulates Star line mode commands, but we can't use this if we want to interact directly with the printer)
This project will take an image file (Either as a PIL image, or from file on disk), scale it to the appropriate width for the printer, and then create a binary output of the graphic mode raster commands, which then can be sent directly to the device. You could use Pillow
or imgkit
to programmatically build images.
For more detailed reading, you can find the graphic mode command manual at: http://www.starasia.com/Download/Manual/star_graphic_cm_en.pdf
Installing
pip install StarTSPImage
Examples
Print a file from disk:
import StarTSPImage
raster = StarTSPImage.imageFileToRaster('file.bmp', cut=True))
printer = open('/dev/usb/lp0', 'wb')
printer.write(raster)
Create a PIL image and print:
import StarTSPImage
from PIL import Image, ImageDraw
image = Image.new('RGB', (500, 500), color='White')
draw = ImageDraw.Draw(image)
draw.ellipse((0, 0, 500, 500), fill='Black')
draw.ellipse((10, 10, 490, 490), fill='White')
raster = StarTSPImage.imageToRaster(image, cut=True)
printer = open('/dev/usb/lp0', "wb")
printer.write(raster)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file StarTSPImage-0.2.6.tar.gz
.
File metadata
- Download URL: StarTSPImage-0.2.6.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f726cc244baad240dcdac4ec387211d46a2d67abe6ce60e366d87b2915acd89 |
|
MD5 | db33a30f4ee79b97aff8e3f258e44723 |
|
BLAKE2b-256 | fcc97a5e541a987910034ab34fb6ea51947c4b324ec274966d976e6125923f9a |