скругление углов у изображения (php) доработал Ибрагим

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function radiusImg($image, $radius, $background){
$img = imagecreatefromjpeg($image);
imagealphablending($img, true);
$width = imagesx($img);
$height = imagesy($img);
$corner = imagecreatetruecolor($radius, $radius);
imagealphablending($corner, false);
$trans = imagecolorallocatealpha($corner, 255, 255, 255, 127);
imagefill($corner, 0, 0, $background);
imagefilledellipse($corner, $radius, $radius, $radius * 2, $radius * 2, $trans);
$positions = array(
array(0, 0),
array($width - $radius, 0),
array($width - $radius, $height - $radius),
array(0, $height - $radius),
);
foreach ($positions as $pos) {
imagecopyresampled($img, $corner, $pos[0], $pos[1], 0, 0, $radius, $radius, $radius, $radius);
$corner = imagerotate($corner, -90, $background, false);
}
return $img;
}
$radius = 50;
$imgPath = 'images/test_img.jpg';
$background = 0xffffff;
$imgCorner = radiusImg($imgPath, $radius, $background);
header('Content-Type: image/png');
imagepng($imgCorner);