PHP保存imagecreatefrompng

I want to save my pngs, but my code does not allow me to create new pngs or overwrite the existing ones. Ideally every time the page is loaded the image would be saved.

<?php
$width = 640;
    $height = 480;  
    $font = 23;

    $string = "This is my text";
    $im = @imagecreatetruecolor($width, $height);
    imagesavealpha($im, true);
    imagealphablending($im, false);
    $white = imagecolorallocatealpha($im, 255, 255, 255, 127);
    imagefill($im, 0, 0, $white);
    $lime = imagecolorallocate($im, 0, 0, 51);
    imagettftext($im, $font, 0, 0, $font - 3, $lime, "./DroidSerif-Bold.ttf", $string);
    $im = imagecreatefrompng("test.png");
    imagedestroy($im);



?>

imagecreateFROMpng as it names indicates creates an image object by reading a .PNG file. In order to save the image as a PNG, you must use the imagepng function:

...
imagettftext($im, $font, 0, 0, $font - 3, $lime, "./DroidSerif-Bold.ttf", $string);
imagepng($im, "test.png");
imagedestroy($im);