<?php
if(isset($_REQUEST['image_for_compress'])){
    $photooo = $_REQUEST['image_for_compress'];
}
else{
    header('Location: index.php');
    exit;
}


  echo $location = "assets/uploads/".$photooo;
            compressedImage($location,$location,60);
    function compressedImage($source, $path, $quality) {
        
        $info = getimagesize($source);

            if ($info['mime'] == 'image/jpeg')
            
                $image = imagecreatefromjpeg($source);

            elseif ($info['mime'] == 'image/gif') 
                $image = imagecreatefromgif($source);

            elseif ($info['mime'] == 'image/png')
                $image = imagecreatefrompng($source);

            imagejpeg($image, $path, $quality);
    }
    
    