0

i have code for image size reducing...& it worked perfectly.but it only reduce quality now i want to reduce width of an image.(min/max - 700px).

<?php
$uploaded_file=time().'.'.end(explode('.',basename($_FILES['uploadedfile']['name'])));
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$uploaded_file);
$img = getimagesize($uploaded_file);
  if ($img['mime'] == 'image/jpeg') 
    {
        $uploadedfile= imagecreatefromjpeg($uploaded_file);
    }
    elseif ($img['mime'] == 'image/gif') 
    {
        $uploadedfile= imagecreatefromgif($uploaded_file);
    }
    elseif ($img['mime'] == 'image/png') 
    {
        $uploadedfile= imagecreatefrompng($uploaded_file);
    }
    else
    {
        die('Unsupported Image Format');
    }
    $quality=50;
    $output=$uploaded_file;
    imagejpeg($uploadedfile, "images/comic/".$output, $quality);
    imagedestroy($uploadedfile);
    unlink($uploaded_file);
?>
John Conde
  • 217,595
  • 99
  • 455
  • 496
  • 4
    http://php.net/manual/en/function.imagecrop.php Cropping http://stackoverflow.com/questions/14649645/resize-image-in-php Resize – Gerton May 08 '15 at 08:54
  • You cannot reduce the width *during* upload. You could reduce it *before* or *after* upload. Which do you want? – Dwayne Towell May 11 '15 at 00:54
  • dear you can ignore word 'during'.., the process which is done in upper code,(where it reduces quality)..at that time i want to reduce image width. – Ketan Joshi May 11 '15 at 05:44

0 Answers0