My Updated code
/*$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$path = $_FILES['file']['tmp_name'];
$filename = file_get_contents($path);*/
/*    
$imgdata = base64_encode($im); // here we got base64 encode value
$idproof = array("encode" => $imgdata,
                 "path" =>$path,
                 "extension" =>$extension,
                 );
echo json_encode($idproof);*/
   $image;
   $image_type;
   $width = 150;
   $height = 150;
   //-----------------------------------------------
   //   Load Image file
   //-----------------------------------------------
   function load($filename) 
   {
       global $image;
       global $image_type;
            $image_info = getimagesize($filename);
            $image_type = $image_info[2];
            if($image_type == IMAGETYPE_JPEG) 
            {
                $image = imagecreatefromjpeg($filename);
            } 
            elseif($image_type == IMAGETYPE_GIF) 
            {
                $image = imagecreatefromgif($filename);
            }
            elseif($image_type == IMAGETYPE_PNG) 
            {
                $image = imagecreatefrompng($filename);
            }
   }
   //-----------------------------------------------
   //   Save Image file
   //-----------------------------------------------
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null)
   {
       global $image;
       global $image_type;
            if( $image_type == IMAGETYPE_JPEG ) 
            {
                imagejpeg($image,$filename,$compression);
            }
            elseif( $image_type == IMAGETYPE_GIF )
            {
                imagegif($image,$filename);
            } 
            elseif( $image_type == IMAGETYPE_PNG )
            {
                imagepng($image,$filename);
            }
            if( $permissions != null ) 
            {
                chmod($filename,$permissions);
            }
   }
   //-----------------------------------------------
   //   View Image file
   //-----------------------------------------------
   function output($image_type=IMAGETYPE_JPEG) 
   {
      global $image;
      global $image_type;
      if( $image_type == IMAGETYPE_JPEG )
      {
         imagejpeg($image);
      } 
      elseif( $image_type == IMAGETYPE_GIF )
      {
         imagegif($image);
      } elseif( $image_type == IMAGETYPE_PNG ) 
      {
         imagepng($image);
      }
   }
   function getWidth() 
   {
      global $image;
      return imagesx($image);
   }
   function getHeight() 
   {
      global $image;
      return imagesy($image);
   }
   //=============================================================================
   //   Resize Images
   //=============================================================================
   //-----------------------------------------------
   //   Resize Images 01 - Resize to Height
   //-----------------------------------------------
   function resizeToHeight($height) 
   {
      $ratio = $height / getHeight();
      $width = getWidth() * $ratio;
      resize($width,$height);
   }
   //-----------------------------------------------
   //   Resize Images 02 - Resize to Width
   //-----------------------------------------------
   function resizeToWidth($width) 
   {
      $ratio = $width / getWidth();
      $height = getheight() * $ratio;
      resize($width,$height);
   }
   //-----------------------------------------------
   //   Resize Images 03 - Scale in %
   //-----------------------------------------------
   function scale($scale) 
   {
      $width = getWidth() * $scale/100;
      $height = getheight() * $scale/100;
      resize($width,$height);
   }
   //-----------------------------------------------
   //   Resize Images 04 - Scale in %
   //-----------------------------------------------
   function resize($width,$height) 
   {
      global $image;
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $image, 0, 0, 0, 0, $width, $height, getWidth(), getHeight());
      $image = $new_image;
   }     
 load($_FILES['file']['tmp_name']);
// To resize based on image width
   
 resizeToWidth($width); 
// To resize based on image height
 resizeToHeight($height); 
// To resize to specific size
   resize($width, $height) ;
$filename = base64_encode(output());
$idproof = array("encode" => $filename,
                 );
echo json_encode($idproof);I am doing one php file upload,in that field user uploads the large image means, i want to re size the image,see here i want like this ,but this code i can't understand,next after re size the image i want to encode that image how can do this one?
<script type="text/javascript">
 $("#idproof").submit(function(e) {
            var formData = new FormData();
            var id = '<?php echo $id;?>';
            formData.append('ssmid', id);
   formData.append('file', $('input[type=file]')[0].files[0]);
              $.ajax({
              url: 'idproof_check.php',
              type: 'POST',
              data: formData,
              async: false,
              cache: false,
              contentType: false,
              processData: false,
              success: function (data) {
                  var res=jQuery.parseJSON(data);// convert the json
                  console.log(res);
              },
             });
             });
</script>
idproof_check.php
<?php
$userid = $_POST['userid'];
 
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$path = $_FILES['file']['tmp_name'];
$im = file_get_contents($path);
/*Here i want to resize the image after that i want to encode the image*/
$filename = base64_encode($im); // here we got base64 encoded value
$idproof = array("encode" => $filename,
                 "path" =>$path,
                 "extension" =>$extension,
                 );
echo json_encode($idproof);
?>  <form method="post" enctype="multipart/form-data" class="form-horizontal" id="idproof" name="myForm">
   <div class="input-group heading1">
    <span class="input-group-btn">
        <span class="btn btn-primary btn-file">
            Browse… <input type="file" id="myFile" name="file" >
        </span>
    </span>
    <input type="text" class="form-control" readonly="">
</div>
 <div class="row">
  <div class="col-md-5 col-md-offset-2">
    <div class="input-group heading1">
    <span class="input-group-btn">
    <button type="submit" class="btn btn-primary btn-md horoscope">Upload ID Proof</button>
    </div>
  </div> 
</div>
</form> 
     
     
    