The picture generated by the GD library comes with a black border when cutting the circle.

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:

clipboard.png

:

clipboard.png

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; 

set a header ("Content-type:image/png") to try?


have you solved it, brother

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e53dc2-4527e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e53dc2-4527e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?