Skip to content

Commit 2a281fc

Browse files
committed
📖 docs
1 parent ffe97df commit 2a281fc

8 files changed

+615
-133
lines changed

docs/API-QROptions.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ Inherited from [`SettingsContainerAbstract`](https://github.com/chillerlan/php-s
5757
| `$scale` | `int` | `5` | * | Pixel size of a QR code module |
5858
| `$imageTransparent` | `bool` | `true` | * | Toggle transparency (no jpeg support), QRGdImage and QRImagick only. The given `QROptions::$transparencyColor` is set as transparent |
5959
| `$transparencyColor` | `mixed` | `null` | a valid GD or Imagick color value | Sets a transparency color for when `QROptions::$imageTransparent` is set to true. Defaults to `QROptions::$bgColor`. |
60-
| `$pngCompression` | `int` | `-1` | `-1...9` | `imagepng()` compression level, -1 = auto |
61-
| `$jpegQuality` | `int` | `85` | `0...100` | `imagejpeg()` quality |
60+
| `$quality` | `int` | `-1` | * | compression quality setting for `imagejpeg()`, `imagepng()`, `imagewebp()`, `Imagick::setImageCompressionQuality()` |
6261
| `$imagickFormat` | `string` | `'png'` | * | ImageMagick output type, see `Imagick::setType()` |
6362
| `$cssClass` | `string` | `'qrcode'` | * | A common css class |
6463
| `$markupDark` | `string` | `'#000'` | * | Markup substitute for dark (CSS value) |

docs/Built-In-Output-QREps.md

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,81 @@
11
# QREps
22

3-
[Class `QREps`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/QREps.php): [Encapsulated Postscript](https://en.wikipedia.org/wiki/Encapsulated_PostScript) (EPS) output
3+
[Class `QREps`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/QREps.php): [Encapsulated Postscript](https://en.wikipedia.org/wiki/Encapsulated_PostScript) (EPS) output.
4+
5+
6+
## Example
7+
8+
See: [EPS example](https://github.com/chillerlan/php-qrcode/blob/main/examples/eps.php)
9+
10+
Set the options:
11+
12+
```php
13+
$options = new QROptions;
14+
15+
$options->outputType = QROutputInterface::EPS;
16+
$options->scale = 5;
17+
$options->drawLightModules = false;
18+
// colors can be specified either as [R, G, B] or [C, M, Y, K] (0-255)
19+
$options->bgColor = [222, 222, 222];
20+
$options->moduleValues = [
21+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
22+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
23+
QRMatrix::M_FINDER => [233, 233, 233], // light (false)
24+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
25+
QRMatrix::M_ALIGNMENT => [233, 233, 233],
26+
QRMatrix::M_DATA_DARK => [0, 0, 0],
27+
QRMatrix::M_DATA => [233, 233, 233],
28+
];
29+
```
30+
31+
32+
Render and save to file:
33+
34+
```php
35+
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
36+
$file = __DIR__.'/qrcode.eps';
37+
38+
(new QRCode($options))->render($data, $file);
39+
```
40+
41+
42+
Push as file download in a browser:
43+
44+
```php
45+
header('Content-type: application/postscript');
46+
header('Content-Disposition: filename="qrcode.eps"');
47+
48+
echo (new QRCode($options))->render($data);
49+
50+
exit;
51+
```
52+
53+
## Additional methods
54+
55+
| method | return | description |
56+
|---------------------------------------------------|----------|--------------------------------------------|
57+
| (protected) `formatColor(array $values)` | `string` | Set the color format string |
58+
| (protected) `module(int $x, int $y, int $M_TYPE)` | `string` | Returns a path segment for a single module |
459

560

661
## Options that affect this module
762

8-
| property | type |
9-
|--------------------------------|----------------|
10-
| `$drawLightModules` | `bool` |
11-
| `$connectPaths` | `bool` |
12-
| `$excludeFromConnect` | `array` |
13-
| `$scale` | `int` |
63+
| property | type |
64+
|-----------------------|---------|
65+
| `$bgColor` | `array` |
66+
| `$connectPaths` | `bool` |
67+
| `$drawLightModules` | `bool` |
68+
| `$excludeFromConnect` | `array` |
69+
| `$scale` | `int` |
1470

1571

1672
### Options that have no effect
1773

1874
| property | reason |
1975
|------------------------|-----------------|
20-
| `$returnResource` | N/A |
21-
| `$imageBase64` | N/A |
22-
| `$bgColor` | not implemented |
23-
| `$drawCircularModules` | not implemented |
2476
| `$circleRadius` | not implemented |
25-
| `$keepAsSquare` | not implemented |
77+
| `$drawCircularModules` | not implemented |
78+
| `$outputBase64` | N/A |
2679
| `$imageTransparent` | N/A |
80+
| `$keepAsSquare` | not implemented |
81+
| `$returnResource` | N/A |

docs/Built-In-Output-QRFpdf.md

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,86 @@
33
[Class `QRFpdf`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/QRFpdf.php): [Portable Document Format](https://en.wikipedia.org/wiki/PDF) (PDF) output via [FPDF](https://github.com/setasign/fpdf)
44

55

6-
## Options that affect this module
6+
## Example
77

8-
| property | type |
9-
|--------------------------------|----------------|
10-
| `$returnResource` | `bool` |
11-
| `$imageBase64` | `bool` |
12-
| `$bgColor` | `mixed` |
13-
| `$drawLightModules` | `bool` |
14-
| `$fpdfMeasureUnit` | `string` |
8+
See: [FPDF example](https://github.com/chillerlan/php-qrcode/blob/main/examples/fpdf.php)
159

10+
Set the options:
1611

17-
### Options that have no effect
12+
```php
13+
$options = new QROptions;
14+
15+
$options->outputType = QROutputInterface::FPDF;
16+
$options->scale = 5;
17+
$options->fpdfMeasureUnit = 'mm'; // pt, mm, cm, in
18+
$options->bgColor = [222, 222, 222]; // [R, G, B]
19+
$options->drawLightModules = false;
20+
$options->moduleValues = [
21+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
22+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
23+
QRMatrix::M_FINDER => [255, 255, 255], // light (false)
24+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
25+
QRMatrix::M_ALIGNMENT => [255, 255, 255],
26+
QRMatrix::M_DATA_DARK => [0, 0, 0],
27+
QRMatrix::M_DATA => [255, 255, 255],
28+
];
29+
```
30+
31+
32+
Render the output:
33+
34+
```php
35+
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
36+
$out = (new QRCode($options))->render($data); // -> data:application/pdf;base64,...
37+
38+
echo $out;
39+
```
40+
41+
42+
Return the `FPDF` instance (will ignore other output options):
43+
44+
```php
45+
$options->returnResource = true;
46+
47+
/** @var \FPDF $fpdf */
48+
$fpdf = (new QRCode($options))->render($data);
1849

19-
| property | reason |
20-
|------------------------|-----------------|
21-
| `$drawCircularModules` | N/A |
22-
| `$circleRadius` | N/A |
23-
| `$keepAsSquare` | N/A |
24-
| `$connectPaths` | N/A |
25-
| `$excludeFromConnect` | N/A |
26-
| `$scale` | not implemented |
27-
| `$imageTransparent` | N/A |
50+
// do stuff with the FPDF instance...
2851

52+
// ...dump output
53+
header('application/pdf');
54+
55+
echo $fpdf->Output('S');
56+
```
57+
58+
59+
## Additional methods
60+
61+
| method | return | description |
62+
|---------------------------------------------------|--------|------------------------------|
63+
| (protected) `initFPDF()` | `FPDF` | Initializes an FPDF instance |
64+
| (protected) `module(int $x, int $y, int $M_TYPE)` | `void` | Renders a single module |
65+
66+
67+
## Options that affect this module
68+
69+
| property | type |
70+
|---------------------|----------|
71+
| `$bgColor` | `array` |
72+
| `$drawLightModules` | `bool` |
73+
| `$fpdfMeasureUnit` | `string` |
74+
| `$outputBase64` | `bool` |
75+
| `$returnResource` | `bool` |
76+
| `$scale` | `ìnt` |
77+
78+
79+
### Options that have no effect
2980

81+
| property | reason |
82+
|------------------------|--------|
83+
| `$circleRadius` | N/A |
84+
| `$connectPaths` | N/A |
85+
| `$drawCircularModules` | N/A |
86+
| `$excludeFromConnect` | N/A |
87+
| `$imageTransparent` | N/A |
88+
| `$keepAsSquare` | N/A |

docs/Built-In-Output-QRGdImage.md

Lines changed: 95 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,104 @@
33
[Class `QRGdImage`](https://github.com/chillerlan/php-qrcode/blob/main/src/Output/QRGdImage.php): [GdImage](https://www.php.net/manual/book.image) raster graphic output (GIF, JPG, PNG)
44

55

6+
## Example
7+
8+
See: [GdImage example](https://github.com/chillerlan/php-qrcode/blob/main/examples/image.php)
9+
10+
Set the options:
11+
```php
12+
$options = new QROptions;
13+
14+
// $outputType can be one of: GDIMAGE_BMP, GDIMAGE_GIF, GDIMAGE_JPG, GDIMAGE_PNG, GDIMAGE_WEBP
15+
$options->outputType = QROutputInterface::GDIMAGE_WEBP;
16+
$options->quality = 90;
17+
// the size of one qr module in pixels
18+
$options->scale = 20;
19+
$options->bgColor = [200, 150, 200];
20+
$options->imageTransparent = true;
21+
// the color that will be set transparent
22+
// @see https://www.php.net/manual/en/function.imagecolortransparent
23+
$options->transparencyColor = [200, 150, 200];
24+
$options->drawCircularModules = true;
25+
$options->drawLightModules = true;
26+
$options->circleRadius = 0.4;
27+
$options->keepAsSquare = [
28+
QRMatrix::M_FINDER_DARK,
29+
QRMatrix::M_FINDER_DOT,
30+
QRMatrix::M_ALIGNMENT_DARK,
31+
];
32+
$options->moduleValues = [
33+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
34+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
35+
QRMatrix::M_FINDER => [233, 233, 233], // light (false)
36+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
37+
QRMatrix::M_ALIGNMENT => [233, 233, 233],
38+
QRMatrix::M_DATA_DARK => [0, 0, 0],
39+
QRMatrix::M_DATA => [233, 233, 233],
40+
];
41+
```
42+
43+
Render the output:
44+
45+
```php
46+
$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
47+
$out = (new QRCode($options))->render($data); // -> data:image/webp;base64,...
48+
49+
printf('<img alt="%s" src="%s" />', $alt, $out);
50+
```
51+
52+
53+
Return the `GdImage` instance/resource (will ignore other output options):
54+
55+
```php
56+
$options->returnResource = true;
57+
58+
/** @var \GdImage|resource $gdImage */
59+
$gdImage = (new QRCode($options))->render($data);
60+
61+
// do stuff with the GdImage instance...
62+
$size = imagesx($gdImage);
63+
// ...
64+
65+
// ...dump output
66+
header('Content-type: image/jpeg');
67+
68+
imagejpeg($gdImage);
69+
imagedestroy($gdImage);
70+
```
71+
72+
73+
## Additional methods
74+
75+
| method | return | description |
76+
|---------------------------------------------------|----------|-------------------------------------------------------------------|
77+
| (protected) `drawImage()` | `void` | Draws the QR image |
78+
| (protected) `dumpImage()` | `string` | Creates the final image by calling the desired GD output function |
79+
| (protected) `module(int $x, int $y, int $M_TYPE)` | `void` | Renders a single module |
80+
| (protected) `setBgColor()` | `void` | Sets the background color |
81+
| (protected) `setTransparencyColor()` | `void` | Sets the transparency color |
82+
83+
684
## Options that affect this module
785

8-
| property | type |
9-
|--------------------------------|----------------|
10-
| `$returnResource` | `bool` |
11-
| `$imageBase64` | `bool` |
12-
| `$bgColor` | `mixed` |
13-
| `$drawLightModules` | `bool` |
14-
| `$drawCircularModules` | `bool` |
15-
| `$circleRadius` | `float` |
16-
| `$keepAsSquare` | `array` |
17-
| `$scale` | `int` |
18-
| `$imageTransparent` | `bool` |
19-
| `$transparencyColor` | `mixed` |
20-
| `$pngCompression` | `int` |
21-
| `$jpegQuality` | `int` |
86+
| property | type |
87+
|------------------------|----------------|
88+
| `$bgColor` | `mixed` |
89+
| `$circleRadius` | `float` |
90+
| `$drawCircularModules` | `bool` |
91+
| `$drawLightModules` | `bool` |
92+
| `$imageTransparent` | `bool` |
93+
| `$quality` | `int` |
94+
| `$keepAsSquare` | `array` |
95+
| `$outputBase64` | `bool` |
96+
| `$returnResource` | `bool` |
97+
| `$scale` | `int` |
98+
| `$transparencyColor` | `mixed` |
2299

23100

24101
### Options that have no effect
25102

26-
| property | reason |
27-
|--------------------------------|--------|
28-
| `$connectPaths` | N/A |
29-
| `$excludeFromConnect` | N/A |
103+
| property | reason |
104+
|-----------------------|--------|
105+
| `$connectPaths` | N/A |
106+
| `$excludeFromConnect` | N/A |

0 commit comments

Comments
 (0)