Пример #1
0
 def get(self,upc=None):
     if upc == None:
         self.write("Please provide a barcode number")
     else:
         if "retailer_id" in self.request.arguments:
             retailer_id = self.get_argument('retailer_id')
         else:
             retailer_id = None
         self.set_header("Content-Type", "image/png")
         upc = upc.encode('ascii','ignore')
         if retailer_id == "PRCCHP001B0001":
             upc = "40" + upc
         if len(upc) == 11 or len(upc) == 12:
             b = barcode('upca',upc,options=dict(includetext=True), scale=2, margin=1)
         elif len(upc) > 12 and len(upc) < 14:
             b = barcode('ean13',upc,options=dict(includetext=True), scale=2, margin=1)
         elif len(upc) == 16:
             b = barcode('ean13',upc[0:13],options=dict(includetext=True), scale=2, margin=1)
         elif len(upc) == 7:
             b = barcode('upca',"41" + upc + "09",options=dict(includetext=True), scale=2, margin=1)
         elif len(upc) == 10:
             # 10-digit (phone numbers) should show an image
             b = Image.open('static/phone_number.png')
         else:
             b = Image.open('static/error.png')
             f = open('errorfile','a')
             f.write(self.request.uri + ',' + self.request.query)
             f.close()
         b.save(self,format='PNG')
 def funcion_pdf47(self,cr,uid,ids,te_factura):
     path = os.getcwd() + '/%s'
     barcode('pdf417', te_factura, options=dict(eclevel=5, columns=15, rows=15), scale=2, data_mode='8bits').save(path % 'te_factura.png')
     with open(path % 'te_factura.png', "rb") as image_file:
         binary = base64.b64encode(image_file.read())
         self.pool.get('account.invoice').write(cr, uid, ids,{'te_factura': binary})
         os.remove(path % 'te_factura.png')
Пример #3
0
 def funcion_pdf47(self, cr, uid, ids, te_factura):
     path = os.getcwd() + '/%s'
     barcode('pdf417',
             te_factura,
             options=dict(eclevel=5, columns=15, rows=15),
             scale=2,
             data_mode='8bits').save(path % 'te_factura.png')
     with open(path % 'te_factura.png', "rb") as image_file:
         binary = base64.b64encode(image_file.read())
         self.pool.get('account.invoice').write(cr, uid, ids,
                                                {'te_factura': binary})
         os.remove(path % 'te_factura.png')
Пример #4
0
 def funcion_pdf47(self, cr, uid, ids, te_factura):
     #PDF417
     #path = os.getcwd() + '/openerp/addons/account_invoice_cl/%s'
     path = os.getcwd() + '/openerp/trunk/account_invoice_cl/%s'
     barcode('pdf417',
             te_factura,
             options=dict(eclevel=5, columns=15, rows=15),
             scale=2,
             data_mode='8bits').save(path % 'te_factura.png')
     with open(path % 'te_factura.png', "rb") as image_file:
         binary = base64.b64encode(image_file.read())
         self.pool.get('pos.order').write(cr, uid, ids,
                                          {'te_electronico': binary})
         os.remove(path % 'te_factura.png')
Пример #5
0
def qrcode():
    # take session.msg and return equivilent QR code
    qrcode=barcode('qrcode', session.msg, options=dict(version=5, eclevel='M'),
        margin=10, data_mode='8-bits')
    response.headers['Content-Type']="image/png"
    qrcode.save(response.body, "PNG")
    return response.body.getvalue()
Пример #6
0
def get_qr_code():
    from elaphe import barcode
    image = barcode('qrcode',
                    'ID:1234|Info: foobar',
                    options=dict(version=9, eclevel='H'),
                    margin=10, data_mode='8bits')
    image.save('2.png')  
Пример #7
0
    def generateDataMatrix(self, sender, postal_object, id_postcard):
        self.mountStr(postal_object.nacional.cep_destinatario)
        self.mountStr(postal_object.destinatario.numero_end_destinatario)
        self.mountStr(sender.cep_remetente)
        self.mountStr(sender.numero_remetente)
        self.mountStr(postal_object.nacional.cep_destinatario)
        self.mountStr('51')
        self.mountStr(postal_object.numero_etiqueta)
        self.mountStr(
            self.normalizeAdditionalServices(postal_object.servico_adicional))
        self.mountStr(id_postcard)
        self.mountStr(postal_object.codigo_servico_postagem)
        self.mountStr(postal_object.destinatario.numero_end_destinatario)
        self.mountStr(
            self.normalizeComplementAddress(
                postal_object.destinatario.complemento_destinatario))
        self.mountStr(
            self.normalizeDeclaredValue(
                postal_object.servico_adicional.valor_declarado))
        self.mountStr(
            self.normalizeTelephone(
                postal_object.destinatario.telefone_destinatario))
        self.mountStr('-00.000000')
        self.mountStr('-00.000000')
        self.mountStr('|')
        self.mountStr(''.ljust(30, ' '))

        byte_io = BytesIO()
        encoder = barcode('datamatrix',
                          self.str_datamatrix,
                          options=dict(),
                          margin=0)
        encoder.save(byte_io, 'png')

        return b64encode(byte_io.getvalue())
Пример #8
0
def make_ticket(ticket):
    '''Takes ticket or deposit object and generates the ticket PNG, saving to 
    model's ticket attribute.'''
    #Create the barcode and scale it up
    bc = barcode('ean13', '000000' + str(ticket.code), scale=5)
    #open the base ticket image
    ticket_png = Image.open(os.path.join(MEDIA_ROOT, 'tickets/base/ticket.png'))
    #paste the barcode into the bottom-right of the ticket
    paste_coords = (694, 2826)
    ticket_png.paste(bc, paste_coords)
    #Draw text onto ticket starting at the left, in line with the barcode
    draw = ImageDraw.Draw(ticket_png)
    font = ImageFont.truetype(os.path.join(MEDIA_ROOT, 'tickets/base/Anonymous.ttf'), 28)
    code_text = 'Ticket code: %s' %ticket.code
    name_text = 'Customer: %s' %ticket.order.fname + " " + ticket.order.lname
    draw.text((660,3250), code_text, fill="#333333", font=font)
    draw.text((660, 3300), name_text, fill="#333333", font=font)
    draw.text((1100,1300), str(ticket.code), fill="#333333", font=font)
    del draw
    #Save it off to the ticket's imagefield
    tf = StringIO.StringIO()
    ticket_png.save(tf, 'PNG')
    ticket_file = InMemoryUploadedFile(tf, None, 'ticket'+str(ticket.code)+'.png', 'image/jpeg', tf.len, None)
    ticket.ticket.save('ticket'+str(ticket.code)+'.png', ticket_file)
    del bc
    del ticket_png
    del font
    del tf
Пример #9
0
def make_ticket(ticket):
    '''Takes ticket or deposit object and generates the ticket PNG, saving to 
    model's ticket attribute.'''
    #Create the barcode and scale it up
    bc = barcode('ean13', '000000' + str(ticket.code), scale=5)
    #open the base ticket image
    ticket_png = Image.open(os.path.join(MEDIA_ROOT,
                                         'tickets/base/ticket.png'))
    #paste the barcode into the bottom-right of the ticket
    paste_coords = (694, 2826)
    ticket_png.paste(bc, paste_coords)
    #Draw text onto ticket starting at the left, in line with the barcode
    draw = ImageDraw.Draw(ticket_png)
    font = ImageFont.truetype(
        os.path.join(MEDIA_ROOT, 'tickets/base/Anonymous.ttf'), 28)
    code_text = 'Ticket code: %s' % ticket.code
    name_text = 'Customer: %s' % ticket.order.fname + " " + ticket.order.lname
    draw.text((660, 3250), code_text, fill="#333333", font=font)
    draw.text((660, 3300), name_text, fill="#333333", font=font)
    draw.text((1100, 1300), str(ticket.code), fill="#333333", font=font)
    del draw
    #Save it off to the ticket's imagefield
    tf = StringIO.StringIO()
    ticket_png.save(tf, 'PNG')
    ticket_file = InMemoryUploadedFile(tf, None,
                                       'ticket' + str(ticket.code) + '.png',
                                       'image/jpeg', tf.len, None)
    ticket.ticket.save('ticket' + str(ticket.code) + '.png', ticket_file)
    del bc
    del ticket_png
    del font
    del tf
Пример #10
0
def generate_qrcode(message,
                    stream=None,
                    eclevel='M',
                    margin=10,
                    data_mode='8bits',
                    format='PNG',
                    scale=2.5):
    """Generate a QRCode, settings options and output."""

    if stream is None:
        stream = StringIO.StringIO()

    img = barcode('qrcode',
                  message,
                  options=dict(version=9, eclevel=eclevel),
                  margin=margin,
                  data_mode=data_mode,
                  scale=scale)

    img.save(stream, format)

    datauri = "data:image/png;base64,%s" % b64encode(stream.getvalue())
    stream.close()

    return datauri
Пример #11
0
def get_barcode(info):
    #  生成二维码
    a = barcode('qrcode', info, options=dict(version=2, eclevel='H'), margin=10, data_mode='8bits')
    # options 中version表示生成二维码的内容密度,可以为1-40
    # eclevel 表示生成二维码图片质量,L,M(默认),Q,H
    # margin 表示边距
    # a.show()
    a.save("hello.png")
Пример #12
0
def get_barcode(info):
    a = barcode(
        'qrcode',
        info,
        options=dict(version=9, eclevel='M'),
        margin=10,
        data_mode='8bits')

    a.show()
Пример #13
0
def generateBarcode(code):
#     if len(code) != 12:
#         print 'La longitud tiene que ser de 12 dígitos [te faltan '+str(12-len(code))+'], ya que el último es check digit'
#         return 0
    bc = barcode('ean13', code, options=dict(includetext=True), scale=2, margin=4)
    try:
        bc.save('barcodes/'+code+'.png')
        return 1
    except IOError:
        print "No fue posible guardar la imagen del código de barras"
        return -1
Пример #14
0
def get_barcode(info):
    #  生成二维码
    a = barcode('qrcode',
                info,
                options=dict(version=2, eclevel='H'),
                margin=10,
                data_mode='8bits')
    # options 中version表示生成二维码的内容密度,可以为1-40
    # eclevel 表示生成二维码图片质量,L,M(默认),Q,H
    # margin 表示边距
    # a.show()
    a.save("hello.png")
Пример #15
0
def gen_test_images(symbology):
    conf = load_module(symbology, *find_module(symbology, ['test']))
    img_prefix = join(IMG_ROOT, symbology)
    try:
        makedirs(img_prefix)
    except:
        pass
    for args in conf.cases:
        img_filename, codestring = args[:2]
        options = args[2] if len(args)>2 else {}
        render_options = dict((args[3] if len(args)>3 else {}), scale=2.0)
        generated = barcode(symbology, codestring, options, **render_options).convert('L')
        generated.save(join(img_prefix, img_filename), 'PNG')
Пример #16
0
    def generate_qrcode(self, force=False):
        if self.qrcode and not force:
            return

        url = BASE_URL + self.get_absolute_url()
        lot_code = barcode('qrcode', url, options={ 'version': 3 }, scale=5, margin=10, data_mode='8bits')

        temp_file_path = os.sep.join((FILE_UPLOAD_TEMP_DIR, 'qrcode.%s.png' % self.bbl))
        
        f = open(temp_file_path, 'wb')
        lot_code.save(f, 'png')
        f = open(temp_file_path, 'rb')
        self.qrcode.save(self.bbl + '.png', File(f))
        self.save()
Пример #17
0
def generate_barcode(format, code):
    if format == '0':
        return
    try:
        # Try to import elaphe
        from elaphe import barcode
        # Generate barcode
        img = barcode(format, code, options={'scale': 1, 'height': 0.5})
        # Format PNG
        f = StringIO()
        img.save(f, 'png')
        f.seek(0)
        return f.getvalue()
    except Exception:
        return
Пример #18
0
def generate_qrcode(message, stream=None, eclevel="M", margin=10, data_mode="8bits", format="PNG", scale=2.5):
    """Generate a QRCode, settings options and output."""

    if stream is None:
        stream = StringIO.StringIO()

    img = barcode(
        "qrcode", message, options=dict(version=9, eclevel=eclevel), margin=margin, data_mode=data_mode, scale=scale
    )

    img.save(stream, format)

    datauri = "data:image/png;base64,%s" % b64encode(stream.getvalue())
    stream.close()
    return datauri
Пример #19
0
def barcodeimg(request, id):

    try:
    	i = Recipe.objects.get(pk=id)
    except Recipe.DoesNotExist:
    	raise Http404

    response=HttpResponse(content_type='image/png')

    url="https://%s/recipemonkeyapp/recipe/scan/%s/" % ('recipemonkey.getoutsideandlive.com',i.id)

    img=barcode('qrcode',url,data_mode='8bits')

    img.save(response, 'PNG')

    return response
Пример #20
0
    def generate_barcode(self, type='ean13', text=True):
        barcode_type = BarcodeType.objects.get(name=type.upper())
        try:
            obj = Barcode.objects.get(product=self, type=barcode_type)
        except:
            fp = StringIO()

            if type == 'ean13':
                barcode_text = self.ean
                code_options = dict(includetext=text,
                                    textfont='Courier New',
                                    textsize=12,
                                    showborder=False)
                margin = 1
                scale = 1.25
                data_mode = None
            if type == 'upca':
                barcode_text = self.upc
                code_options = dict(includetext=text,
                                    textfont='Courier New',
                                    textsize=12,
                                    showborder=False)
                margin = 1
                scale = 1.25
                data_mode = None
            if type == 'qrcode':
                barcode_text = self.amazon_url
                code_options = dict(version=9, eclevel='M')
                margin = 10
                scale = 1
                data_mode = '8bits'

            img = barcode(type,
                          str(barcode_text),
                          options=code_options,
                          margin=margin,
                          scale=scale,
                          data_mode=data_mode)

            img.save(fp, format='PNG')
            file = InMemoryUploadedFile(fp, None,
                                        "%s-%s.png" % (self.onemg, type),
                                        'image/png', fp.len, None)
            obj = Barcode(product=self, type=barcode_type)
            obj.image.save(file.name, file)
            obj.save()
        return obj
Пример #21
0
def barcodeimg(request, id):
    
	try:
		i = GroceryItem.objects.get(pk=id)
	except GroceryItem.DoesNotExist:
		raise Http404

	response=HttpResponse(content_type='image/png')

	url="https://%s/recipemonkeyapp/groceryitem/scan/%s/" % ('recipemonkey.getoutsideandlive.com',i.id)
	
	#img=barcode('qrcode',url,options=dict(eclevel='M'), margin=0, data_mode='8bits')   # Generates PIL.EpsImageFile instance
	img=barcode('qrcode',url,data_mode='8bits')
	#img=img.resize((90,90))

	img.save(response, 'PNG')
	
	return response
Пример #22
0
def pdf417bc(ted):
    bc = barcode(
        'pdf417',
        ted,
        options = dict(
            compact = False,
            eclevel = 5, 
            columns = 13, 
            rowmult = 2, 
            rows = 3
        ),
        margin=20,
        scale=1
    )

    bc.show()
    bc.save('test.png')
    return bc
Пример #23
0
    def generate_qrcode(self, force=False):
        if self.qrcode and not force:
            return

        url = BASE_URL + self.get_absolute_url()
        lot_code = barcode('qrcode',
                           url,
                           options={'version': 3},
                           scale=5,
                           margin=10,
                           data_mode='8bits')

        temp_file_path = os.sep.join(
            (FILE_UPLOAD_TEMP_DIR, 'qrcode.%s.png' % self.bbl))

        f = open(temp_file_path, 'wb')
        lot_code.save(f, 'png')
        f = open(temp_file_path, 'rb')
        self.qrcode.save(self.bbl + '.png', File(f))
        self.save()
Пример #24
0
def generate_qrcode(message, stream=None,
                    eclevel='M', margin=10,
                    data_mode='8bits', format='PNG', scale=1.0):
    ''' Generate a QRCode, settings options and output '''

    if stream is None:
        stream = StringIO.StringIO()

    img = barcode('qrcode', message,
                  options=dict(version=9, eclevel=eclevel),
                  margin=margin, data_mode=data_mode, scale=scale)

    if isinstance(stream, basestring):
        for ext in ('jpg', 'png', 'gif', 'bmp', 'xcf', 'pdf'):
            if stream.lower().endswith('.%s' % ext):
                img.save(stream)
                return stream

    img.save(stream, format)

    return stream
Пример #25
0
 def runTest(self):
     symbology = self.conf.symbology
     img_prefix = join(IMG_ROOT, symbology)
     for args in self.conf.cases:
         img_filename, codestring = args[:2]
         options = args[2] if len(args)>2 else {}
         render_options = dict((args[3] if len(args)>3 else {}), scale=2.0)
         generated = barcode(symbology, codestring, options, **render_options).convert('L')
         loaded = Image.open(join(img_prefix, img_filename)).convert('L')
         diff = None
         try:
             # image size comparison
             self.assertEqual(generated.size, loaded.size)
             # pixel-wize comparison
             diff = ImageChops.difference(generated, loaded)
             diff_bbox = diff.getbbox()
             self.assertIsNone(diff_bbox)
         except AssertionError as exc:
             # generate and show diagnostics image
             if diff:
                 # if diff exists, generate 3-row diagnostics image
                 lw, lh = loaded.size
                 gw, gh = generated.size
                 diag = Image.new('L', (max(lw, gw), (lh+gh+max(lh, gh))))
                 diag.paste(loaded, (0, 0, lw, lh))
                 diag.paste(generated, (0, lh, gw, lh+gh))
                 diag.paste(diff, (0, lh+gh, max(lw, gw), (lh+gh+max(lh, gh))))
             else:
                 # else, just write generated image
                 diag = generated
             sio_img = StringIO()
             diag.convert('L').save(sio_img, 'PNG')
             # reopen sio_img
             sio_img = StringIO(sio_img.getvalue())
             sio_uu = StringIO()
             uuencode(sio_img, sio_uu, name='diag_%s' %img_filename)
             raise AssertionError(
                 'Image difference detected (%s)\n'
                 'uu of generated image:\n----\n%s----\n'
                 %(exc.args, sio_uu.getvalue()))
Пример #26
0
def generate_qrcode(message, stream=None,
                    eclevel='M', margin=10,
                    data_mode='8bits', format='PNG', scale=2.5):
    """ Generate a QRCode, settings options and output."""

    if stream is None:
        stream = BytesIO()

    if isinstance(message, basestring):
        message = message.encode()

    img = barcode('qrcode', message,
                  options=dict(version=9, eclevel=eclevel),
                  margin=margin, data_mode=data_mode, scale=scale)

    img.save(stream, format)

    datauri = "data:image/png;base64,%s"\
        % b64encode(stream.getvalue()).decode("utf-8")
    stream.close()

    return datauri
Пример #27
0
    def generate_barcode(self, type='ean13', text=True):
        barcode_type = BarcodeType.objects.get(name=type.upper())
        try:
            obj = Barcode.objects.get(product=self, type=barcode_type)
        except:
            fp = StringIO()

            if type == 'ean13':
                barcode_text = self.ean
                code_options = dict(includetext=text, textfont='Courier New',
                                           textsize=12, showborder=False)
                margin=1
                scale=1.25
                data_mode=None
            if type == 'upca':
                barcode_text = self.upc
                code_options = dict(includetext=text, textfont='Courier New',
                                           textsize=12, showborder=False)
                margin=1
                scale=1.25
                data_mode = None
            if type == 'qrcode':
                barcode_text = self.amazon_url
                code_options = dict(version=9, eclevel='M')
                margin=10
                scale = 1
                data_mode='8bits'
            
            img = barcode(type, str(barcode_text), options=code_options, margin=margin, scale=scale, data_mode=data_mode)
            
            img.save(fp, format='PNG')
            file = InMemoryUploadedFile(fp, None, "%s-%s.png" % (self.onemg, type),
                                        'image/png', fp.len, None)
            obj = Barcode(product=self, type=barcode_type)
            obj.image.save(file.name, file)
            obj.save()
        return obj
Пример #28
0
 def qrcode(self, input_string, out_file=None):
   """ Mã hóa chuỗi input_string thành ảnh 126x126 QR Code 
   và lưu dưới tên out_file
   
   >>> from lib.barcode import Encoder
   >>> e = Encoder()
   >>> e.qrcode("Any string (max. 2,953 bytes)")
   True
   >>> e.qrcode("Any string (max. 2,953 bytes)", "test.png")
   True
   >>> e.qrcode("Any string (max. 2,953 bytes)", "test.jpg")
   True
   >>> e.qrcode("Any string (max. 2,953 bytes)", "test.jp")
   False
   >>> e.qrcode("Any string (max. 2,953 bytes)", "test")
   False
   >>> e.qrcode("Any string (max. 2,953 bytes)", "")
   False
   >>> e.qrcode("")
   True
   >>> 
   """
   if out_file is None:
     out_file = join(BARCODE_DIRECTORY, 
                     "%s.jpg" % md5(input_string).hexdigest())
   
   try:
     image = barcode('qrcode', input_string, 
                     options=dict(version=9, eclevel='H'),
                     margin=10, data_mode='8bits')
     print out_file
     # TODO: add binary image to cassandra
     image.save(out_file)
     return basename(out_file)
   except (TypeError, KeyError):
     return None
Пример #29
0
        print func, arg
        return func

    return newdeco


@decomaker("asd")
def a():
    print "a"


if __name__ == "__main__":
    a = barcode(
        "qrcode",
        "Hello Barcode Writer In Pure PostScript.",
        options=dict(version=9, eclevel="M"),
        margin=10,
        data_mode="8bits",
    )
    print a
    a.save("1.png")
#    for i in xrange(3):
#        send_mail('Subject here', 'Here is the message %d.'% i, '*****@*****.**',
#    ['*****@*****.**'], fail_silently=False,auth_user='******',auth_password='******')
##    User_Activity.objects.get()


#    q=QueryDict('a=1&b=2&c=3')
#    print q.dict()
#    c=q.dict()
#    del c['a']
NRO_PESO = "1.000 KG"
TIPO_DE_PORTE = "TIPO DE PORTE: "
TIPO_PORTE = "PAGADO"

REF = "REF: "
REFERENCIA = "PRUEBA REFERENCIA"

COD_BULTO = "COD.BULTO: "
CODE_BULTO = "63123410000001201280200"

BUL_CLI = "BUL.CLI: "
PAQ = "PAQ24: "

bc = barcode('code128',
             CODE_BULTO,
             options=dict(eclevel=2, compact=True, columns=100, rows=10),
             margin=0,
             scale=11)

bc.save('codigo_barras.png')

base = Image.open('maxresdefault.jpg').convert('RGBA')

nuevoAncho = 2980

nuevoAlto = 4200

nImg = base.resize((nuevoAncho, nuevoAlto))

# Guarda la imagen
nImg.save('nommmsss.png')
Пример #31
0
 def createBarcode(self, text):
     import elaphe
     self.barcode = elaphe.barcode('qrcode', text, options=dict(version=self.version, eclevel=self.eclevel), data_mode='8bits')
Пример #32
0
#this code, from https://code.google.com/p/elaphe proves that the elaphe 
#   routine works - it produces a .png barcode image file

from elaphe import barcode
myBarcode = barcode('qrcode', 'Hello Barcode Writer In Pure PostScript.', 
                    options=dict(version=9, eclevel='M'),  
                    margin=10, data_mode = '8bits')

#myBarcode.show()  #you can have a look at it, if you want
myBarcode.save('test_barcode.png')
x=1
Пример #33
0
nro_telefono = "96868585"
P_DESTINATARIO = "P_DESTINATARIO "

#Expedicion
exp = "EXP: "
nro_exp = "565685874845478"

#Bultos
BULTOS = "BULTOS: "
BULTOS1de1 = "1 DE 1"
COD_BULTO = "COD.BULTO: "
CODE_BULTO = "63123410000001201280200"

concatenacion = nro_remitente + remitente + prueba_direccion + telf + nro_telefono + P_DESTINATARIO + exp + nro_exp + BULTOS + BULTOS1de1 + COD_BULTO + CODE_BULTO

bc = barcode('code128', concatenacion, options=dict(eclevel=2, compact=True, columns=100, rows=10), margin=0, scale=11)
bc.save('codigo_barras.png')

im = Image.new('RGBA', (1980, 1080), (255,255,255,255))
im.save('etiqueta_sencilla.jpg', dpi =(100,100))

base = Image.open('etiqueta_sencilla.jpg').convert('RGBA')
nuevoAncho=2980
nuevoAlto=4200
nImg = base.resize((nuevoAncho, nuevoAlto))
        # Guarda la imagen
nImg.save('etiqueta_sencilla_paso1.png')
print base.size

# make a blank image for the text, initialized to transparent text color
txt = Image.new('RGBA', base.size, (255,255,255,0))
Пример #34
0
def get_barcode(info):
    a = barcode('qrcode',info,options=dict(version=9, eclevel='M'), margin=10, data_mode='8bits')
    a.show()
def get_code39(info):
    bc = barcode('code39', info, options=dict(includetext=True), scale=3, margin=10)
    bc.save('code39.png', quality=95)
Пример #36
0
from elaphe import barcode
barcode('ISBN', '977147396801', options=dict(includetext=True)).show()
barcode('ISBN', '000034334891').show()
barcode('Ean13', '977147396801').show()
barcode('raw', '000011116801').show()

barcode('qrcode',
        "hello itsa me mario",
        options=dict(version=9, eclevel='M'), 
        margin=10, data_mode='8bits').show()
def get_QRcode(info):
    bc = barcode('QRcode', info, options=dict(version=9, eclevel='M'), margin=10, scale=5)
    bc.save('QRcode.png', quality=95)
Пример #38
0
    be = backend_factory("linux_kernel")
    BrotherQLBackend = be['backend_class']
    devices = glob.glob('/dev/usb/lp*')
    if not devices:
        raise RuntimeError('Please plug in the label printer and rerun this script')
    printer = BrotherQLBackend(devices[0])

for id in range(1,11):
    text = '{:06}'.format(id)

    # Create blank image
    img = Image.new('L', (696, 128), 255)

    # Add DataMatrix barcode
    code = barcode('datamatrix',
                   text,
                   options={'rows': 16, 'columns': 16},
                   margins=10)                              # type: Image
    img.paste(code.rotate(90).resize((128,128)), (0,0))

    # Add ID text
    txt = Image.new('L', (128,35), 255)
    draw = ImageDraw.Draw(txt)
    font = ImageFont.truetype("Ubuntu-Regular.ttf", 30)
    tw,th = draw.textsize(text, font)
    draw.text(((128-tw)//2, 0), text, 0, font=font)
    draw.line((0,34,128,34))
    txt = txt.rotate(90, expand=1)
    img.paste(txt, (128,0))

    img.paste(img, (128+35+15,0))
    img.paste(img, ((128+35+15)*2,0))
Пример #39
0
	def get(self):
		ps = barcode('ean8', '%08d'%self.id, options=dict(version=9, eclevel='M'), margin=10)
		return ps
Пример #40
0
response_body = urlopen(request).read()

orderqueue = json.loads(response_body)




#pprint(orderqueue)
print 'Number of pending orders ' + str(len(orderqueue['orders'])) + '\n'
pprint(orderqueue['orders'][2])
print '========================='
for order in orderqueue['orders']:
 useful = ''
 useful+=(str(order['orderId']))
 useful+=(str(order['shipTo']))
 useful+=(str(order['billTo']))
 #useful+=(str(order['items']))


 print useful
 data = elaphe.barcode('pdf417', zlib.compress(useful,9), options=dict(columns=8, rows=4))
 print type(data)
 data.save("data.png", "PNG")
 data.show()





#print response_body