<?php
$im=$_GET['im'];
$fileName = $im;
$fileNameParts = explode('.', $fileName);
$ext = end($fileNameParts);
$ext;
// if($ext=='webp'){
//       $source_image = imagecreatefromwebp($im);
//       $source_imagex = imagesx($source_image);
//       $source_imagey = imagesy($source_image);
//       list($width, $height, $type) = getimagesize($im);
//       if($width>3000 && $height>1500){
//         $dest_imagex = $width/10;
//         $dest_imagey = $height/5;
           
//       } else{
           
       
       
//         $dest_imagex = $width/5;
//         $dest_imagey = $height/2.5;
           
//       }
//     //  echo  $dest_imagey = $height; exit;
//       $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
//       imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, 
//       $dest_imagex, 
//       $dest_imagey, $source_imagex, $source_imagey);
//       header("Content-Type: image/webp");
//       imagejpeg($dest_image,NULL,80);
// }
// if($ext=='jpeg'){
//       $source_image = imagecreatefromjpeg($im);
//       $source_imagex = imagesx($source_image);
//       $source_imagey = imagesy($source_image);
//       list($width, $height, $type) = getimagesize($im);
//       if($width>3000 && $height>1500){
//         $dest_imagex = $width/10;
//         $dest_imagey = $height/5;
           
//       } else{
           
       
       
//         $dest_imagex = $width/5;
//         $dest_imagey = $height/2.5;
           
//       }
//     //  echo  $dest_imagey = $height; exit;
//       $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
//       imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, 
//       $dest_imagex, 
//       $dest_imagey, $source_imagex, $source_imagey);
//       header("Content-Type: image/jpeg");
//       imagejpeg($dest_image,NULL,80);
// }
if($ext=='jpg'){
      $source_image = imagecreatefromjpg($im);
      $source_imagex = imagesx($source_image);
      $source_imagey = imagesy($source_image);
       list($width, $height, $type) = getimagesize($im);
       if($width>3000 && $height>1500){
        $dest_imagex = $width/10;
        $dest_imagey = $height/5;
           
       } else{
           
       
       
        $dest_imagex = $width/5;
        $dest_imagey = $height/2.5;
           
       }
    //  echo  $dest_imagey = $height; exit;
      $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
      imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, 
      $dest_imagex, 
      $dest_imagey, $source_imagex, $source_imagey);
      header("Content-Type: image/jpg");
      imagejpeg($dest_image,NULL,80);
}
// if($ext=='png'){
//       $source_image = imagecreatefrompng($im);
//       $source_imagex = imagesx($source_image);
//       $source_imagey = imagesy($source_image);
//       list($width, $height, $type) = getimagesize($im);
//       if($width>3000 && $height>1500){
//         $dest_imagex = $width/10;
//         $dest_imagey = $height/5;
           
//       } else{
           
       
       
//         $dest_imagex = $width/5;
//         $dest_imagey = $height/2.5;
           
//       }
//     //  echo  $dest_imagey = $height; exit;
//       $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
//       imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, 
//       $dest_imagex, 
//       $dest_imagey, $source_imagex, $source_imagey);
//       header("Content-Type: image/png");
//       imagejpeg($dest_image,NULL,80);
// }
   ?>
