Reputation: 1051
I am trying to generate a different colored QR Code using phpqrcode library.
My code sample is below:
<?php
include('./phpqrcode/qrlib.php');
$uri=$_GET['uri'];
$backColor = 0xFFFFFF;
$foreColor = 0x000066;
header("Content-Type: image/png");
QRcode::png($uri, false, QR_ECLEVEL_L, 6, 1, false, $backColor, $foreColor);
?>
However, the colors just seem to get ignored and the QR code always comes out as black on white.
I am pretty sure I am using the latest version of the library (v1.1.4):
http://sourceforge.net/projects/phpqrcode/files/releases/
Anyone managed to get this working?
Upvotes: 2
Views: 15263
Reputation: 61
In the qrimage.php
file try to change $col[0]
and $col[1]
values and see the difference, good luck.
Upvotes: 6
Reputation: 39540
The sourceforge version of the method looks like the following:
static QRcode::png (
$text,
$outfile = false,
$level = QR_ECLEVEL_L,
$size = 3,
$margin = 4,
$saveandprint = false
)
and does not include any colours. You seem to be looking for the GitHub version instead, that defines the method as the following:
public static function png(
$text,
$outfile = false,
$level = QR_ECLEVEL_L,
$size = 3,
$margin = 4,
$saveandprint=false,
$back_color = 0xFFFFFF,
$fore_color = 0x000000
) {
(Psst, the article you read also mentions it: "Start by downloading the latest PHP QR Code library from GitHub", and it also includes a link to the GitHub project)
Upvotes: 6