The following example outputs a PNG image at the default size, medium error correction.
<?php
require_once("Image/QRCode.php");
$qr = new Image_QRCode();
$qr->makeCode("Hello, world");
?>
This example will output a JPEG file instead of a PNG.
<?php
require_once("Image/QRCode.php");
$qr = new Image_QRCode();
$options = array(
"image_type" => "jpeg"
);
$qr->makeCode("Hello, world", $options);
?>
If you need the GD object returned instead of outputting direct to the browser, use the following example.
<?php
require_once("Image/QRCode.php");
$qr = new Image_QRCode();
$options = array(
"output_type" => "return"
);
$gd_object = $qr->makeCode("Hello, world", $options);
?>
Image_QRCode supports 4 error correction levels:
<?php
require_once("Image/QRCode.php");
$qr = new Image_QRCode();
$options = array(
"error_correct" => "H"
);
$qr->makeCode("Hello, world", $options);
?>
The size of the generated QR image can be adjusted as follows. This does not affect error correction or similar.
<?php
require_once("Image/QRCode.php");
$qr = new Image_QRCode();
$options = array(
"module_size" => 30
);
$qr->makeCode("Hello, world", $options);
?>
The version of the QR code can be altered by passing options to the constructor. Note that in most cases this will result in an increase in image size.
<?php
require_once("Image/QRCode.php");
$options = array(
"version" => 5
);
$qr = new Image_QRCode($options);
$qr->makeCode("Hello, world");
?>