Beispiel #1
0
 protected function getAsPng($code, $type)
 {
     $barcode = new \TCPDF2DBarcode($code, $type);
     return $barcode->getBarcodePNGData(6, 6, array(0, 0, 0));
 }
Beispiel #2
0
            $h = 2/5 * $w;
            $barcodeObj = new TCPDF2DBarcode($payload, $requested_code_type);
            $barcodeObj->getBarcodePNG($w, $h, [$red, $green, $blue]);
            break;
        
        case 'QR':
            /** Handle raw-looking QR **/
            break;

        case 'FANCYQR':
            /** @TODO handle fancy QR code creation * */
            $imagePadding=12; // @IMPORTANT - make an even number
            $std_wh = max([$w, $h]);
            $w = $size; $h = $size;
            $barcodeObj = new TCPDF2DBarcode($payload, 'QRCODE,H');
            $imgData = $barcodeObj->getBarcodePNGData($w, $h, [$red, $green, $blue]);
            $imgSize = getimagesizefromstring($imgData);
            // get png-8 image 
            $img = imagecreatetruecolor($imgSize[0]+$imagePadding,$imgSize[1]+$imagePadding);
            imagefill($img, 0, 0, imagecolorallocate($img,255,255,255));
            // write temp file
            $temp_filename = TMP_DIR . date('YmdHis') . '__TEMP.PNG';
            file_put_contents($temp_filename, $imgData);
            $imgsrc = imagecreatefrompng($temp_filename);
            // convert to png-24
            $margin = -1 * ($imagePadding/2);
            imagecopy($img,$imgsrc,0,0,$margin,$margin,$imgSize[0]+$imagePadding,$imgSize[1]+$imagePadding);            
            // config
            $matrixPointSize = min(max((int)$size, 1), 50);
            // blur factor
            $i = 50;