diff --git a/CHANGELOG b/CHANGELOG index d137f7e..f93f909 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,3 +22,16 @@ CHANGELOG - Added charcode tables - Fixed Horizontal Tab - Fixed code tabulators + +* 2015-04-21 - Version 1.0.5 +- Merge pull request #45 from Krispy2009/master + . Raising the right error when wrong charcode is used + . Sent by Krispy2009@gmail.com + +* 2015-07-06 - Version 1.0.6 +- Merge pull request #53 from ldos/master + . Extended params for serial printers + . Sent by cafeteria.ldosalzira@gmail.com + +* 2015-08-22 - Version 1.0.7 +- Issue #57: Fixed transparent images diff --git a/README b/README index a60323e..aa08b13 100644 --- a/README +++ b/README @@ -72,7 +72,7 @@ The following example shows how to initialize the Epson TM-TI88IV from escpos import * """ Seiko Epson Corp. Receipt Printer M129 Definitions (EPSON TM-T88IV) """ - Epson = escpos.Escpos(0x04b8,0x0202,0) + Epson = escpos.Escpos(0x04b8,0x0202) Epson.text("Hello World") Epson.image("logo.gif") Epson.barcode @@ -82,8 +82,20 @@ The following example shows how to initialize the Epson TM-TI88IV ------------------------------------------------------------------ 5. Links -Please visit project homepage at: -http://repo.bashlinux.com/projects/escpos.html +Please visit project documentation at: +https://github.com/manpaz/python-escpos/wiki + +------------------------------------------------------------------ +6. Donations + +There are some different prints I'd like to acquire, but unfortunately +not all, even used, are cheaper and easy to get. + +If you want to help funding money to get more printers or just want to +donate because you like the project, please be in touch and I'll be +sending my PayPal info so you can donate. + +Thank you! Manuel F Martinez diff --git a/escpos/escpos.py b/escpos/escpos.py index bea1543..d331b02 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -3,7 +3,7 @@ @author: Manuel F Martinez @organization: Bashlinux @copyright: Copyright (c) 2012 Bashlinux -@license: GPL +@license: GNU GPL v3 """ try: @@ -111,7 +111,15 @@ class Escpos: def image(self,path_img): """ Open image file """ im_open = Image.open(path_img) - im = im_open.convert("RGB") + + # Remove the alpha channel on transparent images + if im_open.mode == 'RGBA': + im_open.load() + im = Image.new("RGB", im_open.size, (255, 255, 255)) + im.paste(im_open, mask=im_open.split()[3]) + else: + im = im_open.convert("RGB") + # Convert the RGB image in printable image self._convert_image(im) @@ -155,6 +163,7 @@ class Escpos: qr_code.make(fit=True) qr_img = qr_code.make_image() im = qr_img._img.convert("RGB") + # Convert the RGB image in printable image self._convert_image(im) diff --git a/escpos/printer.py b/escpos/printer.py index 1de54a3..fd4e9e8 100644 --- a/escpos/printer.py +++ b/escpos/printer.py @@ -3,7 +3,7 @@ @author: Manuel F Martinez @organization: Bashlinux @copyright: Copyright (c) 2012 Bashlinux -@license: GPL +@license: GNU GPL v3 """ import usb.core @@ -70,24 +70,40 @@ class Usb(Escpos): class Serial(Escpos): """ Define Serial printer """ - def __init__(self, devfile="/dev/ttyS0", baudrate=9600, bytesize=8, timeout=1, *args, **kwargs): + def __init__(self, devfile="/dev/ttyS0", baudrate=9600, bytesize=8, timeout=1, + parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, + xonxoff=False , dsrdtr=True, *args, **kwargs): """ @param devfile : Device file under dev filesystem @param baudrate : Baud rate for serial transmission @param bytesize : Serial buffer size @param timeout : Read/Write timeout + + @param parity : Parity checking + @param stopbits : Number of stop bits + @param xonxoff : Software flow control + @param dsrdtr : Hardware flow control (False to enable RTS/CTS) """ Escpos.__init__(self, *args, **kwargs) self.devfile = devfile self.baudrate = baudrate self.bytesize = bytesize self.timeout = timeout + + self.parity = parity + self.stopbits = stopbits + self.xonxoff = xonxoff + self.dsrdtr = dsrdtr + self.open() def open(self): """ Setup serial port and set is as escpos device """ - self.device = serial.Serial(port=self.devfile, baudrate=self.baudrate, bytesize=self.bytesize, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=self.timeout, dsrdtr=True) + self.device = serial.Serial(port=self.devfile, baudrate=self.baudrate, + bytesize=self.bytesize, parity=self.parity, + stopbits=self.stopbits, timeout=self.timeout, + xonxoff=self.xonxoff, dsrdtr=self.dsrdtr) if self.device is not None: print("Serial printer enabled") @@ -160,6 +176,10 @@ class File(Escpos): if self.device is None: print("Could not open the specified file %s" % self.devfile) + def flush(self): + """Flush printing content""" + self.device.flush() + def _raw(self, msg): """ Print any command sent in raw format """ diff --git a/setup.py b/setup.py index 7c2766a..d29ad51 100755 --- a/setup.py +++ b/setup.py @@ -4,9 +4,9 @@ from distutils.core import setup setup( name='escpos', - version='1.0-4', - url='http://code.google.com/p/python-escpos', - download_url='http://python-escpos.googlecode.com/files/python-escpos-1.0.zip', + version='1.0.7', + url='https://github.com/manpaz/python-escpos', + download_url='https://github.com/manpaz/python-escpos.git', description='Python library to manipulate ESC/POS Printers', license='GNU GPL v3', long_description=open('README').read(),