㊙️ 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
Fuzzware is a project for automated, self-configuring fuzzing of firmware images

Fuzzware Fuzzware is a project for automated, self-configuring fuzzing of firmware images. The idea of this project is to configure the memory ranges

190 Dec 21, 2022
PyLibTiff - a wrapper to the libtiff library to Python using ctypes

PyLibTiff is a package that provides: a wrapper to the libtiff library to Python using ctypes. a pure Python module for reading and writing TIFF and L

Pearu Peterson 105 Dec 21, 2022
MaryJane is a simple MJPEG server written in Python.

MaryJane is a simple MJPEG server written in Python.

bootrino 152 Dec 13, 2022
Sombra is simple Raytracer written in pure Python.

Sombra Sombra is simple Raytracer written in pure Python. It's main purpose is to help understand how raytracing works with a clean code. If you are l

Hernaldo Jesus Henriquez Nuñez 10 Jul 16, 2022
NFT collection generator. Generates layered images

NFT collection generator Generates layered images, whole collections. Provides additional functionality. Repository includes three scripts generate.py

Gleb Gonchar 10 Nov 15, 2022
Goddard Image Analysis and Navigation Tool

Copyright 2021 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is clai

NASA 12 Dec 23, 2022
kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns

kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns. The library builds on the

pyxem 53 Dec 29, 2022
A simple image to text converter with GUI!

TEXTEMAGE! Textemage is a quick tool that extracts text from images, it is a Python based GUI program(also available in executable version). This is a

Akascape 5 Oct 26, 2022
A utility for quickly cropping large collections of images.

Crop Tool A utility for quickly cropping large collections of images. Inspired by Derrick Schultz's dataset-tools. Setup It's suggested that you use A

dusk (they/them) 6 Nov 14, 2021
This projects aim is to simulate flowers(Gerbera Daisy) phyllotaxis.

phyllotaxis This projects aim is to simulate flowers(Gerbera Daisy) phyllotaxis. Take a look at the arrangement of this flower's seeds, this project's

amirsalar 3 Dec 10, 2021
A script to generate a profile picture and a banner that show the same image on Discord.

Discord profile picture & banner generator A script to generate a profile picture and a banner that show the same image on Discord. Installation / Upd

Victor B. 9 Nov 27, 2022
Image Processing HighPass Filter With Python

Image_Processing_HighPassFilter High Pass Filter take the high frequency and ignore the low frequency High Pass Filter can be use to sharpening an ima

Felix Pratamasan 1 Dec 27, 2021
Blender addon - convert empty image reference to image plane

Reference to image plane Convert reference images to a textured image mesh plane. As if it was imported with import image as plane Use on drag'n'dropp

Samuel Bernou 6 Nov 25, 2022
BeeRef — A Simple Reference Image Viewer

BeeRef — A Simple Reference Image Viewer BeeRef lets you quickly arrange your reference images and view them while you create. Its minimal interface i

Rebecca 245 Dec 25, 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
Combinatorial image generator for generative NFT art.

ImageGen Stitches multiple image layers together into one image. Run usage: stitch.py [-h] backgrounds_dir dinos_dir traits_dir texture_file

Dinosols NFT 19 Sep 16, 2022
Visage Differentiation is a GUI application for outlining and labeling the visages in an image.

Visage Differentiation Visage Differentiation is a GUI application for outlining and labeling the visages in an image. The main functionality is provi

Grant Randa 0 Jan 13, 2022
python binding for libvips using cffi

README PyPI package: https://pypi.python.org/pypi/pyvips conda package: https://anaconda.org/conda-forge/pyvips We have formatted docs online here: ht

libvips 467 Dec 30, 2022
A quick and dirty QT Statusbar implementation for grabbing GIFs from Tenor, since there is no offical or unofficial one I found. This was intended for use under Linux, however it was also functional enough on MacOS.

Statusbar-TenorGIF App for Linux A quick and dirty QT Statusbar implementation for grabbing GIFs from Tenor, since there is no offical one and I didnt

Luigi DaVinci 1 Nov 01, 2021
Plots the graph of a function with ASCII characters.

ASCII Graph Plotter Plots the graph of a function with ASCII characters. See the change log here. Developed by InformaticFreak (c) 2021 How to use py

InformaticFreak 2 Apr 29, 2022