pip uninstall PIL pip install pillow
python setup.py build python setup.py install
Create Firt example barcode.py and run it:
import sys from hubarcode.code128 import Code128Encoder if __name__ == '__main__': print 'barcode generator' encoder = Code128Encoder(sys.argv[1]) encoder.save("test.png")
python barcode.py 123
Not run:
barcode.py 123
Because it generate error:
ImportError: No module named Image
Below are default options for Code128Encoder:
self.options.get('show_label', True) self.options.get('ttf_fontsize', default_fontsize) self.options.get('ttf_font') self.options.get('label_border', 0) self.image_height = self.options.get('height') or (self.image_width / 3) self.options.get('bottom_border', 0)
Create Custom options:
options['height'] = 25 options['ttf_fontsize'] = 8 options['bottom_border'] = 2