( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php $filename = "v/uploads/raw/cf8b44b8a5faa9f819f1a8c7aac6a168.jpg";
$background_s = imagecreatefromstring(file_get_contents($filename));
$width = imagesx($background_s);
$height = imagesy($background_s);
$newwidth = 500;
$newheight = 500;
$background = imagecreatetruecolor($newwidth, $newheight);
imagealphablending($background, true);
imagecopyresampled($background, $background_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($background, $mask, 0, 0, 0, 0, $newwidth, $newheight, 100);
imagecolortransparent($background,$red);
imagefill($background, 0, 0, $red);
//output, save and free memory
header('Content-type: image/png');
imagepng($background);
imagepng($background,'output.png');
imagedestroy(imagecopy($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2));imagecopy($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2));imagecopy($background, $background2,$background2LEFT-$extraLeft, $background2TOP-$extraTop, 0, 0, imagesx($background2), imagesy($background2));$background);
imagedestroy($mask);?>