
Public Member Functions | |
| __construct ($filename=null, $allowOptimisations=true) | |
| getHeight () | |
| getHeightBytes () | |
| getWidth () | |
| getWidthBytes () | |
| toRasterFormat () | |
| toColumnFormat ($doubleDensity=false) | |
Static Public Member Functions | |
| static | isGdLoaded () |
| static | isImagickLoaded () |
| static | load ($filename, $allowOptimisations=true, array $preferred=['imagick', 'gd', 'native']) |
Protected Member Functions | |
| loadImageData ($filename=null) | |
| setImgData ($data) | |
| setImgWidth ($width) | |
| setImgHeight ($height) | |
| getRasterFormatFromFile ($filename=null) | |
| getColumnFormatFromFile ($filename=null, $highDensityVertical=true) | |
Protected Attributes | |
| $imgHeight = 0 | |
| $imgWidth = 0 | |
This class deals with images in raster formats, and converts them into formats which are suitable for use on thermal receipt printers. Currently, only PNG images (in) and ESC/POS raster format (out) are implemeted.
Input formats:
Output formats:
Libraries:
| Mike42\Escpos\EscposImage::__construct | ( | $filename = null, |
|
$allowOptimisations = true |
|||
| ) |
Construct a new EscposImage.
| string | $filename | Path to image filename, or null to create an empty image. |
| boolean | $allowOptimisations | True (default) to use any library-specific tricks to speed up rendering, false to force the image to be read in pixel-by-pixel, which is easier to unit test and more reproducible between systems, but slower. |
|
protected |
| string | $filename | Filename to load from |
| boolean | $highDensityVertical | True for high density output (24px lines), false for regular density (8px) |
| Mike42\Escpos\EscposImage::getHeight | ( | ) |
| Mike42\Escpos\EscposImage::getHeightBytes | ( | ) |
|
protected |
| string | $filename | Filename to load from |
| Mike42\Escpos\EscposImage::getWidth | ( | ) |
| Mike42\Escpos\EscposImage::getWidthBytes | ( | ) |
|
static |
|
static |
|
static |
This is a convinience method to load an image from file, auto-selecting an EscposImage implementation which uses an available library.
The sub-classes can be constructed directly if you know that you will have Imagick or GD on the print server.
| string | $filename | File to load from |
| bool | $allowOptimisations | True to allow the fastest rendering shortcuts, false to force the library to read the image into an internal raster format and use PHP to render the image (slower but less fragile). |
| array | $preferred | Order to try to load libraries in- escpos-php supports pluggable image libraries. Items can be 'imagick', 'gd', 'native'. |
| Exception | Where no suitable library could be found for the type of file being loaded. |
|
protected |
Load an image from disk. This default implementation always gives a zero-sized image.
| string | null | $filename | Filename to load from. |
|
protected |
Set image data.
| string | $data | Image data to use, string of 1's (black) and 0's (white) in row-major order. |
|
protected |
Set image height.
| int | $height | height of the image. |
|
protected |
Set image width.
| int | $width | width of the image |
| Mike42\Escpos\EscposImage::toColumnFormat | ( | $doubleDensity = false | ) |
Output the image in column format.
| boolean | $doubleDensity | True for double density (24px) lines, false for single-density (8px) lines. |
| Mike42\Escpos\EscposImage::toRasterFormat | ( | ) |
Output the image in raster (row) format. This can result in padding on the right of the image, if its width is not divisible by 8.
| Exception | Where the generated data is unsuitable for the printer (indicates a bug or oversized image). |
|
protected |
height of the image.
|
protected |
width of the image
1.8.8