PHP method of two-dimensional code to add logo

The method of adding the logo PHP dimensional code
<pre>
public function createqcode ($ text, $ ID) {
the include '/phpqrcode/phpqrcode.php';

Level = $ "L";
// Each dot two-dimensional code image pixels, the default. 4
$ size = '10';
// frame pitch two-dimensional code, the default 2
$ padding = 2;
$ path = __ DIR__. '/../../../Public/images/qcode/'.$id.'.jpg';
// generate two-dimensional code images
\ QRcode :: png ($ text, $ path, $ level, $ size, $ padding, true);


. $ logo = __DIR __ '/ .. / .. / .. / Public / images / logo.png'; // ready logo image
$ QR = $ path; // original two-dimensional code that has been generated in FIG
$ the QR imagecreatefromstring = (file_get_contents ($ the QR));
$ = imagecreatefromstring logo (file_get_contents ($ logo));
$ QR_width = imagesx ($ the QR); // two-dimensional code image width
$ QR_height = imagesy ($ QR) ; // two dimensional code image height
$ logo_width = imagesx ($ logo) ; // logo image width
$ logo_height = imagesy ($ logo) ; // logo image height
$ $ QR_width logo_qr_width = /. 5;
$ logo_width Scale = $ / $ logo_qr_width;
$ = $ logo_height logo_qr_height / $ Scale;
$ from_width = (QR_width $ - $ logo_qr_width) / 2;
// recombined image and resize
imagecopyresampled ($ QR, $ logo, $ from_width, $ from_width, 0, 0, $ logo_qr_width,
$ logo_qr_height, $ logo_width, $ logo_height );


imagepng (the QR $, $ path);
$ WebUrl = '/ baiqueyaoqing2 / Images / qcode /'.$ ID.' JPG ';.
return $ WebUrl;
}
</ pre>
simply merge function is to use php GD

Guess you like

Origin www.cnblogs.com/newmiracle/p/11871477.html