Skip to content

The repository includes installation instructions and usage examples, making it a convenient and customizable solution for generating Code 128 barcodes using Python.

Notifications You must be signed in to change notification settings

abbeymichael/Barcodes-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

This is a Python code that generates barcodes using the barcode module. The barcodes are generated using the code128 format and the barcode images are saved in the current working directory. Installation

The barcode module can be installed using pip. Open the terminal and run the following command:

pip install python-barcode

Usage

The code uses the barcode.writer.ImageWriter() class to generate the barcode images. The barcode images are saved in the current working directory.

The start_value variable is used to set the starting value of the barcode. The num_barcodes variable is used to set the number of barcodes to be generated.

The barcode_width and barcode_height variables are used to set the width and height of the barcode image.

The code loops through the range of start_value and start_value + num_barcodes and generates a barcode for each value in the range. The barcode image is saved with the name of the value in the range with leading zeros to make the filename 7 digits long.

The options variable is used to set the options for the barcode image. The module_width and module_height variables are used to set the size of the barcode modules. The quiet_zone variable is used to set the size of the quiet zone around the barcode. The write_text variable is used to remove the text below the barcode, and the font_size variable is used to set the font size of the text above the barcode. Example

To generate 3000 barcodes starting from 1234567, with a width of 60 and a height of 30, run the following code:

python

import barcode from barcode.writer import ImageWriter

start_value = 1234567 num_barcodes = 3000

Set the width and height of the barcode image

barcode_width = 60 barcode_height = 30

for i in range(start_value, start_value + num_barcodes): code = barcode.get('code128', '{:07d}'.format(i), writer=ImageWriter())

# Set the options for the barcode image
options = {'module_width': 0.3, 'module_height': 5.0, 'quiet_zone': 10.0}
options['write_text'] = True  # Remove the text below the barcode
options['font_size'] = 10  # Set the font size of the text above the barcode

# Set the size of the barcode image
options['width'] = barcode_width
options['height'] = barcode_height

code.save(f"{i:07d}", options=options)

This will generate 3000 barcode images in the current working directory, starting from 1234567. Each barcode image will have a width of 60 and a height of 30.

https://github.com/abbeymichael/Barcodes-Generator/blob/main/outcome.jpg

About

The repository includes installation instructions and usage examples, making it a convenient and customizable solution for generating Code 128 barcodes using Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages