• Stars
    star
    249
  • Rank 162,987 (Top 4 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

barcode.php - Generate barcodes from a single PHP file. MIT license.

barcode.php

Generate barcodes from a single PHP file. MIT license.

  • Output to PNG, GIF, JPEG, or SVG.
  • Generates UPC-A, UPC-E, EAN-13, EAN-8, Code 39, Code 93, Code 128, Codabar, ITF, QR Code, and Data Matrix.

Use directly as a PHP script with GET or POST:

barcode.php?f={format}&s={symbology}&d={data}&{options}

e.g.

barcode.php?f=png&s=upc-e&d=06543217
barcode.php?f=svg&s=qr&d=HELLO%20WORLD&sf=8&ms=r&md=0.8

When using this method, you must escape non-alphanumeric characters with URL encoding, for example %26 for & or %2F for ?.

Or use as a library from another PHP script:

include 'barcode.php';

$generator = new barcode_generator();

/* Output directly to standard output. */
header("Content-Type: image/$format");
$generator->output_image($format, $symbology, $data, $options);

/* Create bitmap image and write to standard output. */
header('Content-Type: image/png');
$image = $generator->render_image($symbology, $data, $options);
imagepng($image);
imagedestroy($image);

/* Create bitmap image and write to file. */
$image = $generator->render_image($symbology, $data, $options);
imagepng($image, $filename);
imagedestroy($image);

/* Generate SVG markup and write to standard output. */
header('Content-Type: image/svg+xml');
$svg = $generator->render_svg($symbology, $data, $options);
echo $svg;

/* Generate SVG markup and write to file. */
$svg = $generator->render_svg($symbology, $data, $options);
file_put_contents($filename, $svg);

When using this method, you must NOT use URL encoding.

Options:

f - Format. One of:

    png
    gif
    jpeg
    svg

s - Symbology (type of barcode). One of:

    upc-a          code-39         qr     dmtx
    upc-e          code-39-ascii   qr-l   dmtx-s
    ean-8          code-93         qr-m   dmtx-r
    ean-13         code-93-ascii   qr-q   gs1-dmtx
    ean-13-pad     code-128        qr-h   gs1-dmtx-s
    ean-13-nopad   codabar                gs1-dmtx-r
    ean-128        itf

d - Data. For UPC or EAN, use * for missing digit. For Codabar, use ABCD or ENT* for start and stop characters. For QR, encode in Shift-JIS for kanji mode.

w - Width of image. Overrides sf or sx.

h - Height of image. Overrides sf or sy.

sf - Scale factor. Default is 1 for linear barcodes or 4 for matrix barcodes.

sx - Horizontal scale factor. Overrides sf.

sy - Vertical scale factor. Overrides sf.

p - Padding. Default is 10 for linear barcodes or 0 for matrix barcodes.

pv - Top and bottom padding. Default is value of p.

ph - Left and right padding. Default is value of p.

pt - Top padding. Default is value of pv.

pl - Left padding. Default is value of ph.

pr - Right padding. Default is value of ph.

pb - Bottom padding. Default is value of pv.

bc - Background color in #RRGGBB format.

cs - Color of spaces in #RRGGBB format.

cm - Color of modules in #RRGGBB format.

tc - Text color in #RRGGBB format. Applies to linear barcodes only.

tf - Text font for SVG output. Default is monospace. Applies to linear barcodes only.

ts - Text size. For SVG output, this is in points and the default is 10. For PNG, GIF, or JPEG output, this is the GD library built-in font number from 1 to 5 and the default is 1. Applies to linear barcodes only.

th - Distance from text baseline to bottom of modules. Default is 10. Applies to linear barcodes only.

ms - Module shape. One of: s for square, r for round, or x for X-shaped. Default is s. Applies to matrix barcodes only.

md - Module density. A number between 0 and 1. Default is 1. Applies to matrix barcodes only.

wq - Width of quiet area units. Default is 1. Use 0 to suppress quiet area.

wm - Width of narrow modules and spaces. Default is 1.

ww - Width of wide modules and spaces. Applies to Code 39, Codabar, and ITF only. Default is 3.

wn - Width of narrow space between characters. Applies to Code 39 and Codabar only. Default is 1.

More Repositories

1

bitsnpicas

Bits'N'Picas - Bitmap & Emoji Font Creation & Conversion Tools
Java
315
star
2

open-relay

Free and open source fonts from Kreative Software
Shell
161
star
3

openxion

OpenXION - Reference Implementation of the XION Scripting Language
Java
66
star
4

vexillo

Kreative Vexillo - http://www.kreativekorp.com/app/vexillo/ - Images and emoji fonts of nothing but flags, and the software to generate them.
JavaScript
32
star
5

powerpaint

Kreative PowerPaint - Library and Application for Bitmap and Vector Image Editing
Java
30
star
6

sitelen-seli-kiwen

handwritten sitelen pona font
HTML
23
star
7

hexcellent

A hex editor. Be hexcellent to each other.
Java
16
star
8

neopixelpusher

Control software for Adafruit NeoPixels.
C++
14
star
9

ksfl

KSFL - Kreative Structured Format Library
Java
12
star
10

rainbowdash

RainbowDashboard Advanced Firmware for Rainbowduino
Java
11
star
11

iconposeur

Open-source recreation of the Icon Composer application. Create icons for Mac OS X without Xcode. Also creates Windows ico files.
Java
10
star
12

petscii8

PETSCII-8 is an 8-bit encoding with the goal of being compatible with both ASCII and PETSCII.
Assembly
9
star
13

resplendence

Mac OS Classic and DFF resource editor
Java
8
star
14

u8m

U8/M - UTF-8 for Microcomputers
Assembly
6
star
15

classic-crayons

Mac OS Classic's crayon color picker but for Mac OS X
Objective-C
4
star
16

voynich-unicode

Fonts which encode characters from the Voynich Manuscript
3
star
17

pushchar

A Unicode character picker.
Java
3
star
18

charset

The data repository backing http://www.kreativekorp.com/charset/
Python
3
star
19

desktopresetter

Safely rebuild the Mac OS Classic desktop database
C
2
star
20

swatches

A highly versatile Mac OS X color picker
Objective-C
1
star
21

4d

Firmware and companion desktop software for 4D Systems LCD modules.
Java
1
star
22

spritelet

Spritelet v2
C++
1
star
23

dx-oed

dX: Overengineered Electronic Die
C++
1
star
24

charsets

Implementations of character encodings originating from legacy computers
Java
1
star
25

kgb

The useful parts of this repository have been moved to separate repositories.
Java
1
star
26

pixelpusher

Control software for Heroic Robotics PixelPusher LED driver.
Java
1
star
27

animal-prints

View and convert Animal Crossing design patterns
Java
1
star