home/autoph/public_html/projects/api/app/Controllers/QRController.php 0000644 00000003652 15025020646 0022073 0 ustar 00 json(array("status" => 0, "message" => "data parameter is required."));
}
$label = input('label') ? input('label') : '';
$image = input('logo') ? config('qr')->logo : config('qr')->no_logo;
$result = Builder::create()
->writer(new PngWriter())
->writerOptions([])
->data(input('data'))
->encoding(new Encoding('UTF-8'))
->errorCorrectionLevel(new ErrorCorrectionLevelHigh())
->size(300)
->margin(10)
->roundBlockSizeMode(new RoundBlockSizeModeMargin())
->logoPath($image)
->labelText($label)
->labelFont(new NotoSans(20))
->labelAlignment(new LabelAlignmentCenter())
->build();
// Directly output the QR code
header('Content-Type: ' . $result->getMimeType());
if (!empty(input('filename'))) {
header("Content-Disposition: inline;filename=" . input('filename') . ".png");
}
echo $result->getString();
// Save it to a file
// $result->saveToFile(__DIR__ . '/qrcode.png');
// Generate a data URI to include image data inline (i.e. inside an
tag)
$dataUri = $result->getDataUri();
}
}