使用PHP中的数据创建图像时如何设置图像大小?

I have created image using dataimage url using php, how to set a image size when creation time, I have used below php code.

   $imageData=$_POST['post_data']; 
   $filteredData=substr($imageData, strpos($imageData, ",")+1);
   $unencodedData=base64_decode($filteredData);
   $fp = fopen( 'img/test/test.png', 'wb' );
   fwrite( $fp, $unencodedData);

Please anyone help

Here is the updated code.

$imageData=$_POST['post_data']; 
$filteredData=substr($imageData, strpos($imageData, ",")+1);
$unencodedData=base64_decode($filteredData);
$src = imagecreatefromstring($unencodedData);
$width = imagesx($src);
$height = imagesy($src);
$new_w = 200;
$new_h = 300;
$img = imagecreatetruecolor($new_w,$new_h); 
imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
imagejpeg($im, 'image.jpg');
imagedestroy($im);