㊙️ 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
Python binding to Skia Graphics Library

Skia python binding Python binding to Skia Graphics Library. Binding based on pybind11. Currently, the binding is under active development. Install Bi

Kota Yamaguchi 170 Jan 06, 2023
Forza painter app with python

forza-painter Discord: A-Dawg#0001 (AE) Supports: Forza Horizon 5 Offically (OTHER v1.405.2.0, MS STORE v3.414.967.0, STEAM v1.414.967.0) Unofficially

320 Dec 31, 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 Python3 library to generate dynamic SVGs

The Python library for generating dynamic SVGs using Python3

1 Dec 23, 2021
Image2scan - a python program that can be applied on an image in order to get a scan of it back

image2scan Purpose image2scan is a python program that can be applied on an image in order to get a scan of it back. For this purpose, it searches for

Kushal Shingote 2 Feb 13, 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
The aim is to extract timeseries water level 2D information for any designed boundaries within the EasyGSH model domain

bct_file_generator_for_EasyGSH The aim is to extract timeseries water level 2D information for any designed boundaries within the EasyGSH model domain

Clayton Soares 1 Jul 08, 2022
sK1 2.0 cross-platform vector graphics editor

sK1 2.0 sK1 2.0 is a cross-platform open source vector graphics editor similar to CorelDRAW, Adobe Illustrator, or Freehand. sK1 is oriented for prepr

sK1 Project 238 Dec 04, 2022
Script for the creation of metadatas and the randomization of images of MekaVerse

MekaVerse-random Script for the creation of metadata and the randomization of images of MekaVerse Step to replay the random : Create a folder : output

Miinded 8 Sep 07, 2022
API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language

You can try it @ api-fatoora api-fatoora API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language Disclaime

نافع الهلالي 12 Oct 05, 2022
Console images in 48 colors, 216 colors and full rgb

console_images Console images in 48 colors, 216 colors and full rgb Full RGB 216 colors 48 colors If it does not work maybe you should change color_fu

Урядов Алексей 5 Oct 11, 2022
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
A Icon Maker GUI Made - Convert your image into icon ( .ico format ).

Icon-Maker-GUI A Icon Maker GUI Made Using Python 3.9.0 . It will take any image and convert it to ICO file, for web site favicon or Windows applicati

Insanecodes 12 Dec 15, 2021
The friendly PIL fork (Python Imaging Library)

Pillow Python Imaging Library (Fork) Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lund

Pillow 10.4k Dec 31, 2022
View images in the terminal using ansi escape codes and python

terminal-photo-viewer view images in the terminal using ansi escape codes and python !! Only tested on Ubuntu 20.04.3 LTS with python version 3.8.10 D

1 Nov 30, 2021
Pixel art as well as various sets for hand crafting

Pixel art as well as various sets for hand crafting

1 Nov 09, 2021
Command line utility for converting images to seamless tiles

img2texture Command line utility for converting images to seamless tiles. The resulting tiles can be used as textures in games, compositing and 3D mod

Artёm IG 24 Dec 26, 2022
An application that maps an image of a LaTeX math equation to LaTeX code.

Convert images of LaTex math equations into LaTex code.

1.3k Jan 06, 2023
Python modules to work with large multiresolution images.

Large Image Python modules to work with large, multiresolution images. Large Image is developed and maintained by the Data & Analytics group at Kitwar

Girder 136 Jan 02, 2023
【萝莉图片算法】高损图像压缩算法!?

【萝莉图片算法】高损图像压缩算法!? 我又发明出新算法了! 这次我发明的是新型高损图像压缩算法——萝莉图片算法!为什么是萝莉图片,这是因为它是使动用法,让图片变小所以是萝莉图片,大家一定要学好语文哦! 压缩效果 太神奇了!压缩率竟然高达99.97%! 与常见压缩算法对比 在图片最终大小为1KB的情况

黄巍 49 Oct 17, 2022