@@ -13,16 +13,15 @@ Requirements
1313Requires the following components:
1414
1515* PHP >= 5.4
16- * Fileinfo extension
17- * GD extension
16+ * PHP extensions: bcmath, fileinfo, gd
1817
1918Installation
2019------------
2120
2221Add it to your ` composer.json ` file:
2322
2423```
25- composer require bigfish/pdf417 ~0.1
24+ composer require bigfish/pdf417 ^1.0.0
2625```
2726
2827Usage overview
@@ -59,6 +58,68 @@ $renderer = new SvgRenderer([
5958$svg = $renderer->render($data);
6059```
6160
61+ ImageRenderer
62+ -------------
63+
64+ Renders the barcode to an image using [ Intervention Image] ( http://image.intervention.io/ )
65+
66+ Render function returns an instance of ` Intervention\Image\Image ` .
67+
68+ #### Options
69+
70+ Option | Default | Description
71+ ------- | ------- | -----------
72+ format | png | Output format, one of: ` jpg ` , ` png ` , ` gif ` , ` tif ` , ` bmp ` , ` data-url `
73+ quality | 90 | Jpeg encode quality (1-10)
74+ scale | 3 | Scale of barcode elements (1-20)
75+ ratio | 3 | Height to width ration of barcode elements (1-10)
76+ padding | 20 | Padding in pixels (0-50)
77+ color | #000000 | Foreground color as a hex code
78+ bgColor | #ffffff | Background color as a hex code
79+
80+ #### Examples
81+
82+ ``` php
83+ $pdf417 = new PDF417();
84+ $data = $pdf417->encode("My hovercraft is full of eels");
85+
86+ // Create a PNG image, red on green background, extra big
87+ $renderer = new ImageRenderer([
88+ 'format' => 'png',
89+ 'color' => '#FF0000',
90+ 'color' => '#00FF00',
91+ 'scale' => 10,
92+ ]);
93+
94+ $image = $renderer->render($data);
95+ $image->save('hovercraft.png');
96+ ```
97+
98+ The ` data-url ` format is not like the others, it returns a base64 encoded PNG
99+ image which can be used in an image ` src ` or in CSS. When you create an image
100+ using this format:
101+
102+ ``` php
103+ $pdf417 = new PDF417();
104+ $data = $pdf417->encode('My nipples explode with delight');
105+
106+ $renderer = new ImageRenderer([
107+ 'format' => 'data-url'
108+ ]);
109+ $img = $renderer->render($data);
110+ ```
111+
112+ You can use it directly in your HTML or CSS code:
113+
114+ ``` html
115+ <img src =" <?= $img->encoded ?>" />
116+ ```
117+
118+ And this will be rendered as:
119+ ``` html
120+ <img src =" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA.... " />
121+ ```
122+
62123Thanks
63124------
64125
0 commit comments