Download the PHP package webcooking/zpl-to-image without Composer
On this page you can find all versions of the php package webcooking/zpl-to-image. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webcooking/zpl-to-image
More information about webcooking/zpl-to-image
Files in webcooking/zpl-to-image
Package zpl-to-image
Short Description A PHP library to convert ZPL content to SVG images or GDImage objects
License LGPL-3.0-or-later
Informations about the package zpl-to-image
ZPL to Image Converter
A PHP library to convert ZPL (Zebra Programming Language) content into images. Generates SVG output with support for TrueType fonts and GDImage conversion.
Features
This library provides 3 types of ZPL conversion:
- ZPL → SVG (
ZplToSvg) - Vector rendering with TrueType fonts - ZPL → Imagick (
ZplToImagick) - Rasterization via rsvg-convert or Imagick - ZPL → GDImage (
ZplToGdImage) - PNG/JPEG export
Requirements
- PHP 8.0 or higher
- GD extension enabled
- Imagick extension (for SVG to GDImage conversion)
- Install:
pecl install imagick - Or:
apt-get install php-imagick(Linux) - Or:
brew install imagemagick+pecl install imagick(macOS)
- Install:
- rsvg-convert (optional but highly recommended for reliable rasterization)
- Install:
apt-get install librsvg2-bin(Linux) - Or:
brew install librsvg(macOS) - Automatically used when available, provides better SVG compatibility
- Install:
Installation
Clone the repository and run Composer install:
Usage
Method 1: Generate SVG (Recommended)
Available Fonts
Built-in fonts:
'noto'- Noto Sans - DEFAULT'ibm-vga'- IBM VGA 8x16
Custom fonts:
- Provide a path to any
.ttffile:'/path/to/your/font.ttf'
Method 2: Convert to GDImage (Raster with Imagick)
Method 3: Direct File Export (PNG/JPEG)
Method 4: Get an Imagick object directly
If you prefer to work with Imagick directly (for advanced processing, composites or filters), use ZplToImagick which returns an Imagick object.
Font Comparison
| Font | Style | File Size |
|---|---|---|
| Noto Sans | Modern, clean | ~1.9 MB |
| IBM VGA | Retro, pixel style | ~35 KB |
Testing
Run the example test scripts:
See the examples/ folder for more details.
Creating your own tests
- Create a
.zplfile in theexamples/folder - Test it:
php examples/test.php your_file.zpl
Docker testing
A Docker environment is provided for consistent testing with all dependencies:
The Docker environment includes rsvg-convert for reliable rasterization, solving potential blank image issues.
Supported ZPL Commands
Currently supports:
^A0N: Font settings (height, width)^FO: Field origin (position x,y)^FN: Field number (for data association)^FD: Field data (text content)^FR: Field reverse (white text on black)^GB: Graphic box (rectangles, lines, filled boxes)^BCN: Barcode Code 128
More commands can be added as needed.
Troubleshooting
Issue: Blank/White JPG Images
Problem: Generated JPEG/PNG images appear completely white or blank, even though SVG output is correct.
Cause: Some Imagick installations don't properly handle SVG files with embedded fonts (data URLs in @font-face rules).
Solution: The library detects and uses rsvg-convert when available. All classes automatically use the best available renderer:
-
Install rsvg-convert (recommended):
-
Docker setup (if using containerization):
- Verify installation:
When rsvg-convert is available, the library automatically uses it for SVG rasterization, providing much better compatibility with embedded fonts and complex SVG elements. If rsvg-convert is not available, it falls back to direct Imagick conversion.
Resources
License
Project: LGPL-3.0-or-later
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Fonts:
- Noto Sans: SIL Open Font License 1.1 (see
fonts/Noto_Sans/OFL.txt) - IBM VGA: Creative Commons CC BY-SA 4.0 by VileR (int10h.org) (see
fonts/IBM_VGA/LICENSE)
Support
If you use this package in a commercial or paid project and find it helpful, I'd be grateful if you considered offering a small token of thanks : https://ko-fi.com/nuranto
No pressure — this is only if the library saved you time and you feel like supporting future work.