hudora / hubarcode Goto Github PK
View Code? Open in Web Editor NEWhuBarcode is a Python Library to generate 1D and 2D Barcodes
Home Page: http://github.com/mdornseif/huBarcode
huBarcode is a Python Library to generate 1D and 2D Barcodes
Home Page: http://github.com/mdornseif/huBarcode
def create_qr_code_pic(data):
code_str = "!|"
code_str += data+"|"
code_str += "@"
(dir,file_name) = get_unique_file_name2(file_pre="qr")
code_image_path = os.path.join(settings.MEDIA_ROOT,'uploads',dir)
if not os.path.exists(code_image_path):
os.mkdir(code_image_path)
code_image_file_name = '%s/%s.png' % (code_image_path, file_name)
ENCODER = QRCodeEncoder(code_str.encode('gbk'))
ENCODER.save(code_image_file_name)
return '%s/%s.png' % (dir, file_name)
and the error message:
...
File "/root/deploy/divo3/apps/check/views/commons.py", line 140, in create_qr_code_pic
ENCODER = QRCodeEncoder(code_str.encode('gbk'))
File "/usr/lib/python2.5/site-packages/hubarcode/qrcode/init.py", line 29, in init
self.matrix = enc.encode(text, ecl)
File "/usr/lib/python2.5/site-packages/hubarcode/qrcode/textencoder.py", line 83, in encode
self.create_matrix()
File "/usr/lib/python2.5/site-packages/hubarcode/qrcode/textencoder.py", line 207, in create_matrix
matrix_content = self.minfo.create_matrix(self.version, self.codewords)
File "/usr/lib/python2.5/site-packages/hubarcode/qrcode/isodata.py", line 109, in create_matrix
codeword_i = codewords[i]
IndexError: list index out of range
Hi,
I can get the data matrix images in a 80x80 pixel format but i'm not able to change the size of this image either increase or decrease the image by , lets say 50%(40x40 pixel) or 150%(120x120 pixel).
i have tried altering the .height and .width parameter but i think they are for bar codes and not for data matrix.
is there a solution for this?
Sir,
First of all I would really like to thank you for making such a nice and good script for developing 2D barcodes and keeping it in open license formats.
Actually I am trying to build a simple application for myself, and for a kind of secrecy, I want the answers (output) to be printed and circulated using the datamatrix encodings. As the datamatrix encoding procedure is defined by ISO and is not freely available, I looked upon your code for help.
I have seen the examples and it was really easy to understand how to implement your script. But the problem is I have dealt with python in only its 3.x version and I do not know much about 2.x It would be really helpful if you could tell, till when would you release the script in 3.x or help in converting the present script (only the datamatrix part) in 3.x
Thank you very much for reading my mail,
Ayush
3rd yr,
B.E., Computer department
Delhi College of Engineering
This code produces the same bardcodes (the readable text changes, but the barcodes are the same). The first is missing the 9.
from hubarcode.code128 import Code128Encoder
encoder = Code128Encoder('123456789')
encoder.save('test1.png')
encoder = Code128Encoder('12345678')
encoder.save('test2.png')
hi,
please throws exception instead of sys.exit, when data is too big.
may stop a running web service... :)
The title shall say it all.
Some documentation apart from the samples would be nice
this took me a while to figure out:
the qrcode implementation won't work if installed via the current trunk , because the qrcode_data directory isn't installed along with it.
the qrcode_generate_Data.py script doesn't seem to work either, because it doesn't like the way stuff is laid out
my inelegant fix was to migrate the qrcode_data that was in trunk into the python egg.
hongshan liu writes:
hi,Maximillian Dornseif,
I was using your huBarcode,but I found some bugs when I using it.
bug example1:
# -- coding: utf-8 --
# author: liu hongshan email: hongshan.liu@...
from hubarcode.qrcode import QRCodeEncoder
if name == "main":
test = "12345"
ENCODER = QRCodeEncoder(test)
ENCODER.save( "test.png",3)
bug info:
File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/textencoder.py", line 207, in create_matrix
matrix_content = self.minfo.create_matrix(self.version, self.codewords)
File "/home/works/hudora-huBarcode-7a9d83e/hubarcode/qrcode/isodata.py", line 109, in create_matrix
codeword_i = codewords[i]
IndexError: list index out of range
could you fix these? thank you!
Any chance we can get a new release cut and uploaded to PyPI? It's been two years since the last one, and certain changes (#16 in particular) would be nice to have. Thanks!
Please add licensing information to the library. Preferably an open source license. :-)
hongshan liu writes:
hi,Maximillian Dornseif,
I was using your huBarcode,but I found some bugs when I using it.
bug example2:
# -- coding: utf-8 --
# author: liu hongshan email: [email protected]
from hubarcode.qrcode import QRCodeEncoder
if name == "main":
test = "TEL:13516190008" #i found when len(test)==15,the result image could not be decoded!
ENCODER = QRCodeEncoder(test)
ENCODER.save( "test.png",3)
could you fix these? thank you!
It would be nice if there was some usage documentation for this library! Specifically options and import steps would be appreciated.
When using pip install huBarcode, sub-packages are installed in root lib dir.
Example:
/usr/local/lib/python2.6/dis-packages/code128
Should be
/usr/local/lib/python2.6/dis-packages/hubarcode/code128
Also, 'fonts' directory is not installed.
I'm having trouble render an image of QR code (works for DataMatrix).
from hubarcode.qrcode import QRCodeEncoder
qr = QRCodeEncoder("m103")
qr_raw_ascii = qr.get_ascii()
print(qr_raw_ascii) # works
qr_raw_img = qr.get_imagedata()
print(qr_raw_img) # prints error listed below
Traceback (most recent call last):
File "D:/py_workspace/otf_barcode/source/test", line 6, in <module>
qr_raw_img = qr.get_imagedata()
File "C:\Python27\lib\site-packages\hubarcode\qrcode\__init__.py", line 44, in get_imagedata
imagedata = qrc.get_imagedata(cellsize)
File "C:\Python27\lib\site-packages\hubarcode\qrcode\renderer.py", line 53, in get_imagedata
img = self.get_pilimage(cellsize)
File "C:\Python27\lib\site-packages\hubarcode\qrcode\renderer.py", line 33, in get_pilimage
self.add_border(colour=0, width=4)
File "C:\Python27\lib\site-packages\hubarcode\qrcode\renderer.py", line 26, in add_border
for i in range(0, self.mtx_size - (width * 2))]
IndexError: list index out of range
Am I doing something wrong?
Too bad huBarcode doesn't work with Python3.
I'd submit a patch, but I'm pretty new to libraries and git too so... here is what I did to make huBarcode work for python3 (or... at least the parts I need to generate a datamatrix):
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
It appears that the install problem not copy hubarcode/qrcode/qrcode_data dir to '/usr/lib/python2.5/site-packages/huBarcode-0.61_r0-py2.5.egg/hubarcode/qrcode/qrcode_data/'.
I've downloaded the latest version of huBarcode from the cheeseshop, and when I attempt to follow the datamatrix sample in the python interpreter, I get an import error.
>>> from hubarcode.datamatrix import DataMatrixEncoder
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python27\lib\site-packages\hubarcode-0.63-py2.7.egg\hubarcode\datamatrix\__init__.py
", line 39, in <module>
from renderer import DataMatrixRenderer
File "c:\python27\lib\site-packages\hubarcode-0.63-py2.7.egg\hubarcode\datamatrix\renderer.py
", line 6, in <module>
import Image
ImportError: No module named Image
Is there a dependency I'm not aware of?
I use this software and our legal page attributes the correct license. I'm writing a dynamic way of getting the licenses for current versions of the packages we use. One of the strategies is pulling the LICENSE file for a given version from release branches on github or whatever hosting provider the project in question is using.
Currently, the latest (and only) release branch tagged on this project is 0.6.2, even though the PyPI package and commit comments indicate that 0.63 is the latest version. A simple version bump tag would be in order.
Also, the versioning convention should be reviewed and sync'd between github and PyPI. I imagine the "current" version is supposed to be 0.6.3 rather than 0.63.
This package has conflicting license information.
On one hand, the README
file states the following:
The code is available under the Apache License, Version 2.0.
On the other, the setup.py
file contains the following:
'License :: OSI Approved :: BSD License',
And the README
also contains this:
If you worry about copyright you might consider this Software BSD-Licensed.
If you are still worried, you might consider it GPL1/2/3 compatible.
If this package is Apache 2.0 licensed, this is incorrect; the Apache 2.0 license is not compatible with versions of the GPL before v3.
I'd recommend picking a single license, placing the license text in a LICENSE
file, and changing all references in the README
, setup.py
, and elsewhere to match.
Would it be possible to add the possible list of export format? I'm particularly interested to know if it could export as EPS format or SVG format. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.