I want to crop a circle image using PHP but it seems that my new image have some transparent pixels. Of course, I want ONLY the outside area of the ellipse to have backgroun
I couln't get it done with Alain's code either. After some time understanding what each line of code does, here is my fix..
//this creates a pink rectangle of the same size
$mask = imagecreatetruecolor($imgwidth, $imgheight);
$pink = imagecolorallocate($mask, 255, 0, 255);
imagefill($mask, 0, 0, $pink);
//this cuts a hole in the middle of the pink mask
$black = imagecolorallocate($mask, 0, 0, 0);
imagecolortransparent($mask, $black);
imagefilledellipse($mask, $imgwidth/2, $imgheight/2, $imgwidth, $imgheight, $black);
//this merges the mask over the pic and makes the pink corners transparent
imagecopymerge($img, $mask, 0, 0, 0, 0, $imgheight, $imgheight);
imagecolortransparent($img, $pink);
imagepng($img, "my_circle.png");