㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.

Overview

python-barcode

CI status Build coverage documentation version on pypi downloads licence

python-barcode provides a simple way to create barcodes in Python.

There are no external dependencies when generating SVG files. Pillow is required for generating images (e.g.: PNGs).

Support Python 3.6 to 3.9.

python-barcode

Documentation

Full documentation is published at http://python-barcode.rtfd.io/

Licence

python-barcode is licensed under the MIT licence. See LICENCE for details.

Comments
  • Unable to import barcode

    Unable to import barcode

    i already install barcode module from official python site like "pip install python-barcode". but whenever i write a code on text editor like 1-Visual Studio 2-SubLime 3-Pycharm theirs an error pop up and it's says "Unable to import 'barcode' pylint(input-error)[1,1]"

    question 
    opened by Soumalya-Mondal 11
  • Cannot save as png after packaging into exe file

    Cannot save as png after packaging into exe file

    微信截图_20200426105205

    Traceback (most recent call last):
      File "site-packages\PIL\ImageFont.py", line 186, in __init__
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 9: ordinal not in range(128)
    

    This error occurs under python3.6, how to solve it

    opened by Yinjiafeng 10
  • TypeError running # Example with PNG in usage guide

    TypeError running # Example with PNG in usage guide

    I'm running Python 3.5.5. A subsection of the usage guide:

    import barcode
    from barcode.writer import ImageWriter
    EAN = barcode.get_barcode_class('code128')
    ean = EAN(u'5901234123457', writer=ImageWriter())
    

    ...gives me the following error:

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-67-21778fac1b87> in <module>()
    ----> 1 ean = EAN(u'5901234123457', writer=ImageWriter())
    
    TypeError: 'NoneType' object is not callable
    

    Am I doing something wrong?

    opened by DannyDannyDanny 9
  • Pillow dreprecation warning about ImageFont.getsize

    Pillow dreprecation warning about ImageFont.getsize

    Hello!

    Pillow 9.2.0 is installed in my virtualenv and when I use python-barcode there is a deprecation warning about the method ImageFont.getsize.

    virtualenv/lib/python3.9/site-packages/barcode/writer.py:441: DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead.
        width, height = font.getsize(subtext)
    

    Since the version 9.2, getsize is deprecated and replaced by getlength. See the PR https://github.com/python-pillow/Pillow/pull/6381.

    opened by brvoisin 7
  • Using 'raw' without using 'save' gives no output

    Using 'raw' without using 'save' gives no output

    I think the title explains it all.

    If I try to use .raw to server an SVG barcode without using .save first, I get an empty output...

    Example: Trying to serve this in my django project:

    class APIBarcode(View):
    
        def get(self, request, *args, **kwargs):
            uuid = request.GET.get('uuid')
            C39 = barcode.get_barcode_class('code39')
            toserve = C39(uuid)
            toserve.save('c39code')
            return HttpResponse(toserve.raw, content_type="image/svg+xml")
    

    Gives the following output: image

    But serving this:

    class APIBarcode(View):
    
        def get(self, request, *args, **kwargs):
            uuid = request.GET.get('uuid')
            C39 = barcode.get_barcode_class('code39')
            toserve = C39(uuid)
            # toserve.save('c39code')
            return HttpResponse(toserve.raw, content_type="image/svg+xml")
    

    Gives the following output:

    image

    If someone can point me to where I should be looking I would gladly attempt to fix it!

    opened by sharifanani 6
  • fix wrong bar width in ImageWriter

    fix wrong bar width in ImageWriter

    fixes #79 and maybe others?

    This might seem trivial, but took me a couple of minutes to track it down. I'm attaching false-colored images for reference. Please pay attention to the final white bar in particular. SvgWriter is not affected as the rectangle implementation is different.

    DPI 300

    before before

    after after

    DPI 100

    before

    after

    opened by fostermaier 5
  • Fix issue #171 calculating checksum before any controls

    Fix issue #171 calculating checksum before any controls

    Moved super().__init__ before calling _calculate_checksum() to check if the string contains any letters to prevent value errors that can happen when calculating checksum. I tested the new version with the input 0132354187 and the produced barcode before and after the commit is the same as 9780132352.

    opened by canklot 5
  • Adds support for longer guard bar to EAN13 and EAN8

    Adds support for longer guard bar to EAN13 and EAN8

    This PR tries to partially solve Issue #11

    Adds a parameter to both classes that controls if we want longer guard bars and then while building the code to be generated, use "G" instead of "1" in those places we will need to have a longer bar.

    During the write, interpret every "G" the same as "1" but add an height factor to the mod list. To avoid changing the entire code base to add a height parameter, set the self.module_height for every bar generated.

    opened by Governa 5
  • Bug in new version in generate?

    Bug in new version in generate?

    In the new version if I try to use:

    import barcode
    barcode.generate('ean13', '123455559121112')
    

    I get an error TypeError: get() got an unexpected keyword argument 'writer_options' I get this both in version 0.12 and 0.13. Is there something I can do about this, or is this a bug?

    bug 
    opened by RosanneZe 5
  • EAN-13/GTIN-13 barcodes don't contain grouping

    EAN-13/GTIN-13 barcodes don't contain grouping

    According to the specs I've found, GTIN-13/EAN-13 barcodes must contain the grouping most commonly found on printed barcodes, i.e. the first character is outside of the code area, and the remainder is in two groups with elongated bars separating the groups.

    Is there any support for this planned? How about the '>' mark for silent areas?

    opened by jfinkhaeuser 5
  • Fix deprecation warning about ImageFont.getsize

    Fix deprecation warning about ImageFont.getsize

    python-barcode/barcode/writer.py:441: DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead. width, height = font.getsize(subtext)

    ImageFont.getsize is deprecated since the version 9.2 of Pillow. We use anchor instead of computing the right position to have an aligned text.

    It is related to the issue #163. The solution was suggested by @nulano (contributor of Pillow).

    opened by brvoisin 4
  • Basic support for MSI / Plessey

    Basic support for MSI / Plessey

    also allows encoding of strings and bytestrings (allows encoding any symbol) by converting them to int ; in this case, string representation is shown in human-readable string

    opened by petaflot 5
  • Implement PZN8

    Implement PZN8

    Implement PZN8 code generation. Fixes #167.

    • keeping PZN for PZN7, implementing PZN8 for PZN8
    • checksum is commonly part of the PZN* code. Hence, we verify or append the checksum based on the length of the supplied PZN7 or PZN8 code.
    • explicit error messages concerning code length for both classes respectively
    • different checksum calculation for PZN8. see http://www.pruefziffernberechnung.de/P/PZN.shtml

    usage

    check code length

    >>> PZN('12345678')
    barcode.errors.NumberOfDigitsError: PZN7 must have 6 digits (excluding checksum) or 7 digits (including checksum), not 8.
    >>> PZN8('123456789')
    barcode.errors.NumberOfDigitsError: PZN8 must have 7 digits (excluding checksum) or 8 digits (including checksum), not 9.
    

    auto-append checksum

    >>> PZN('123456')
    <PZN7('PZN-1234562')>
    >>> PZN8('1234567')
    <PZN8('PZN-12345678')>
    

    verify checksum if supplied

    >>> PZN('1234568')
    barcode.errors.BarcodeError: Checksum (last digit) is not valid for the supplied PZN7 code.
    >>> PZN('1234562')
    <PZN7('PZN-1234562')>
    

    resources (mostly german)

    • checksum details http://www.pruefziffernberechnung.de/P/PZN.shtml
    • official specification https://www.ifaffm.de/de/ifa-codingsystem/codierung-pzn-code_39.html

    samples

    PZN7: https://barcode.tec-it.com/de/Health_PZN7 pzn7

    PZN8: https://www.softmatic.com/de/barcode-code-pzn.html pzn8

    opened by fostermaier 1
  • UPC/UPCA final output doesn't include guard bars

    UPC/UPCA final output doesn't include guard bars

    I'm being told (not a barcode format specialist) that the standard presentation for a UPC/UPCA code should look like this:

    image

    If I generate this barcode using the following code however, I get this:

    image

    Issues:

    Added "F" at the end?

    Any way to turn this off?

    Guardbars not displayed

    As I seem to understand, the standard/typical presentation for those code should include guardbars. I tried adding the "guardbars" keywords but it seems the UPC class doesn't accept that argument.

    Code:

    python-barcode create 686254053919 upc

    Also generated as part of a server-side rendering, with same result:

    UPCA(str(value["code"]), writer=SVGWriter(), guardbars=True).write(file)

    opened by logikonabstractions 1
  • Text placement in ImageWriter

    Text placement in ImageWriter

    I believe text is incorrectly located in barcode when using ImageWriter as of 0.14.0. This is mainly due to a wrong computation of text height which is a very common problem due to the fact that total height for a font is different from the height of rendered glyphs for most of the ascii characters.

    Attached is a proposed patch to place text correctly. Note that because most of the time a barcode is followed by a text with capital letters, the blank space at the bottom is more that 1mm (which would be nice to set as an option). It should be closer to 1mm when using letters that goes below the font baseline ('p', 'q', etc).

    text_placement.patch.txt

    opened by tytouf 2
Wand is a ctypes-based simple ImageMagick binding for Python

Wand Wand is a ctypes-based simple ImageMagick binding for Python, supporting 2.7, 3.3+, and PyPy. All functionalities of MagickWand API are implement

Eric McConville 1.2k Jan 03, 2023
👾 Python project to help you convert any image into a pixel art.

👾 Pixel Art Generator Python project to help you convert any image into a pixel art. ⚙️ Developer's Guide Things you need to get started with this co

Atul Anand 6 Dec 14, 2022
Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom

Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom. Also, rasterize shapefile vectors as corresponding label image.

Gounari Olympia 2 Nov 22, 2021
A Blender add-on to create interesting meshes using symmetry

Procedural Symmetries This Blender add-on automates the process of iteratively applying a set of reflection planes to a base mesh. The result will con

1 Dec 29, 2021
Image histogram remapping

Hmap An image histogram remapping script written in Python 2.7 by Anthony Kesich and Ross Goodwin. Changes source image so that source image's histogr

Ross Goodwin 199 Nov 19, 2022
Computational Xmas Tree lights!

Computational Xmas Tree This repo contains the code for the computational illumination of a Christmas Tree! It is based on the work by Matt Parker fro

GSD6338 146 Dec 23, 2022
Python pygame project that turns your images to matrix rain

Matrix-Rain-An-Image This project implements the classic Matrix digital rain effect in python with pygame to build up an image provided with multiple

7 Dec 11, 2022
starfish is a Python library for processing images of image-based spatial transcriptomics.

starfish: scalable pipelines for image-based transcriptomics starfish is a Python library for processing images of image-based spatial transcriptomics

199 Dec 08, 2022
A simple python script to reveal the contents of a proof of vaccination QR code.

vaxidecoder A simple python script to reveal the contents of a proof of vaccination QR code. It takes a QR code image as input, and returns JSon data.

Hafidh 2 Feb 28, 2022
Create a 2D mesh for an airfoil in GMSH using python.

GMSHFoil A simple class to create a 2D mesh for an airfoil in GMSH using python. Requirements pip install airfoils

Charilaos Mylonas 1 May 16, 2022
ProsePainter combines direct digital painting with real-time guided machine-learning based image optimization.

ProsePainter Create images by painting with words. ProsePainter combines direct digital painting with real-time guided machine-learning based image op

Morphogen 276 Dec 17, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major bi

CISiP Lab 39 Nov 25, 2022
3D printer / slicing GUI built on top of the Uranium framework

Cura Ultimaker Cura is a state-of-the-art slicer application to prepare your 3D models for printing with a 3D printer. With hundreds of settings and h

Ultimaker 4.4k Jan 02, 2023
Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.

django-image-cropping django-image-cropping is an app for cropping uploaded images via Django's admin backend using Jcrop. Screenshot: django-image-cr

Jonas und der Wolf GmbH 546 Jan 03, 2023
Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Python

AICSImageIO Image Reading, Metadata Conversion, and Image Writing for Microscopy Images in Pure Python Features Supports reading metadata and imaging

Allen Institute for Cell Science - Modeling 137 Dec 14, 2022
Magic-Square - Creates a magic square by randomly generating a list until the list happens to be a magic square

Magic-Square Creates a magic square by randomly generating a list until the list happens to be a magic square. Done as simply as possible... Frequentl

Nick 2 Jan 01, 2022
Water marker for images.

watermarker linux users: To fix this error,please add truetype font path File "watermark.py", line 58, in module font = ImageFont.truetype("Dro

13 Oct 27, 2022
Simple Python image processing & automatization project for a simple web based game

What is this? Simple Python image processing & automatization project for a simple web based game Made using only Github Copilot (except the color and

SGeri 2 Aug 15, 2022
Next-generation of the non-destructive, node-based 2D image graphics editor

Non-destructive, node-based 2D image graphics editor written in Python, focused on simplicity, speed, elegance, and usability

Gimel Studio 238 Dec 30, 2022
Dynamic image server for web and print

Quru Image Server - dynamic imaging for web and print QIS is a high performance web server for creating and delivering dynamic images. It is ideal for

Quru 84 Jan 03, 2023