( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php $filename = "v/uploads/raw/cf8b44b8a5faa9f819f1a8c7aac6a168.jpg";
$backgroundX_s = imagecreatefromstring(file_get_contents($filename));
$width = imagesx($backgroundX_s);
$height = imagesy($backgroundX_s);
$newwidth = 200;
$newheight = 200;
$backgroundX = imagecreatetruecolor($newwidth, $newheight);
imagealphablending($backgroundX, true);
imagecopyresampled($backgroundX, $backgroundX_s, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//create masking
$mask = imagecreatetruecolor($newwidth, $newheight);
$transparent = imagecolorallocate($mask, 255, 0, 0);
imagecolortransparent($mask,$transparent);
imagefilledellipse($mask, $newwidth/2, $newheight/2, $newwidth, $newheight, $transparent);
$red = imagecolorallocate($mask, 0, 0, 0);
imagecopymerge($backgroundX, $mask, 0, 0, 0, 0, $newwidth, $newheight, 100);
imagecolortransparent($backgroundX,$red);
imagefill($backgroundX, 0, 0, $red);
//output, save and free memory
header('Content-type: image/png');
imagepng($backgroundX);
imagepng($backgroundX,'output.png');
imagedestroy(imagecopy);?>