use PHP"s GD library to generate posters, and then cut the QR code into a circle and put it in a specified location. I found all the codes on the Internet, but now I still encounter that the QR code has been cut into a circle, but the picture has its own black border. Locally generated images are transparent, so ask if there is a solution. Thank you.
question:
:
Code:
$w = 200; $hobby 200; / / original size
$original_path= $url;
$dest_path = $path.uniqid().".png";
$src = imagecreatefromstring(file_get_contents($original_path));
$per = 2.6;
$w = $w*$per;
$h = $h*$per;
$newpic = imagecreatetruecolor($w,$h);
imagealphablending($newpic,false);
$transparent = imagecolorallocatealpha($newpic, 255, 255, 255, 127);
$r=$w/2;
for($x=0;$x<$w;$xPP)
for($y=0;$y<$h;$yPP){
$c = imagecolorat($src,$x,$y);
$_x = $x - $w/2;
$_y = $y - $h/2;
if((($_x*$_x) + ($_y*$_y)) < ($r*$r)){
imagesetpixel($newpic,$x,$y,$c);
}else{
imagesetpixel($newpic,$x,$y,$transparent);
}
}
imagesavealpha($newpic, true);
imagepng($newpic, $dest_path);
imagedestroy($newpic);
imagedestroy($src);
return $dest_path;