㊙️ 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
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
Image Processing - Make noise images clean

影像處理-影像降躁化(去躁化) (Image Processing - Make Noise Images Clean) 得力於電腦效能的大幅提升以及GPU的平行運算架構,讓我們能夠更快速且有效地訓練AI,並將AI技術應用於不同領域。本篇將帶給大家的是 「將深度學習應用於影像處理中的影像降躁化 」,

2 Aug 04, 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
Convert photos to paintings with python

Convert-photos-to-paintings Before the changes After the changes Before the changes After the changes This code is written in the Python programming l

Amir Hussein Sharifnezhad 3 May 31, 2022
SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

SimpleITK is an image analysis toolkit with a large number of components supporting general filtering operations, image segmentation and registration

672 Jan 05, 2023
Fixes 500+ mislabeled MURA images

In this repository, new csv files are provided that fixes 500+ mislabeled MURA x-rays for all categories. The mislabeled x-rays mainly had hardware in them. This project only fixes the false negative

Pieter Zeilstra 4 May 18, 2022
HTML2Image is a lightweight Python package that acts as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

176 Jan 01, 2023
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
Panel Competition Image Generator

Panel Competition Image Generator This project was build by a member of the NFH community and is open for everyone who wants to try it. Relevant links

Juliano Mendieta 1 Oct 22, 2021
Plots is a graph plotting app for GNOME.

Plots is a graph plotting app for GNOME. Plots makes it easy to visualise mathematical formulae. In addition to basic arithmetic operations, it supports trigonometric, hyperbolic, exponential and log

Alex Huntley 138 Dec 14, 2022
With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen

Oraxen-item-to-yml With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen How to use Install the

Akex 1 Dec 29, 2021
Quickly 'anonymize' all people in an image. This script will put a black bar over all eye-pairs in an image

Face-Detacher Quickly 'anonymize' all people in an image. This script will put a black bar over all eye-pairs in an image This is a small python scrip

Don Cato 1 Oct 29, 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
Imutils - A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.

imutils A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, and displ

PyImageSearch 4.3k Jan 01, 2023
LSB Image Steganography Using Python

Steganography is the science that involves communicating secret data in an appropriate multimedia carrier, e.g., image, audio, and video files

Mahmut Can Gönül 2 Nov 04, 2021
PIX is an image processing library in JAX, for JAX.

PIX PIX is an image processing library in JAX, for JAX. Overview JAX is a library resulting from the union of Autograd and XLA for high-performance ma

DeepMind 294 Jan 08, 2023
Simple program to easily view Euler parameters in 3D.

Simple program to easily view Euler parameters in 3D.

5 Aug 20, 2021
MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images

MetaStalk About MetaStalk is a tool that can be used to generate graphs from the metadata of JPEG, TIFF, and HEIC images, which are tested. More forma

Cyb3r Jak3 1 Jul 05, 2021
A tool for hiding data inside of images

Stegenography-tool a tool for hiding data inside of images Quick test: do python steg-encode.py test/message.txt test/covid19.png to generate the test

luke 2 Nov 02, 2021
GPU-accelerated image processing using cupy and CUDA

napari-cupy-image-processing GPU-accelerated image processing using cupy and CUDA This napari plugin was generated with Cookiecutter using with @napar

Robert Haase 16 Oct 26, 2022