function reflection(&$img,$perc=50,$maxAlpha=127)
{
$src_height = imagesy($img);
$src_width = imagesx($img);
$dest_height = $src_height + ($src_height / (100/$perc));
$dest_width = $src_width;
$reflected = imagecreatetruecolor($dest_width, $dest_height);
imagealphablending($reflected, false);
imagesavealpha($reflected, true);
imagecopy($reflected, $this->img, 0, 0, 0, 0, $src_width, $src_height);
$reflection_height = $src_height / 2;
for($y=$src_height;$y<$dest_height;$y++)
{
$alpha = (($y-$src_height)/($dest_height-$src_height))*$maxAlpha;
for($x=0;$x<$src_width;$x++)
{
$rgba = imagecolorat($img, $x, $src_height - ($y-$src_height+1));
$rgba = imagecolorsforindex($img, $rgba);
$rgba = imagecolorallocatealpha($reflected, $rgba['red'], $rgba['green'], $rgba['blue'], $alpha);
imagesetpixel($reflected, $x, $y, $rgba);
}
}
$img = $reflected;
}
Source: https://habr.com/ru/post/41231/