上传时缩小图像宽度

时间:2015-05-08 08:50:03

标签: php

我有减少图像尺寸的代码......&它工作得很好。但现在我只想降低质量,我想减少图像的宽度。(最小/最大 - 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);
?>

0 个答案:

没有答案