PHP ITwebinfo.com - 调整jpeg图像的大小

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP ITwebinfo.com - 调整jpeg图像的大小相关的知识,希望对你有一定的参考价值。

<?

/*this can be used to resize image in jpeg format only
which provive a good quality thumbnails*/
// This is the temporary file created by PHP

$uploadedfile = $_FILES['simage']['tmp_name'];

// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);

// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);
$newwidth=300;
//$newheight=($height/$width)*100;
$newheight=200;
$tmp=imagecreatetruecolor($newwidth,$newheight);

// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = $_FILES['simage']['name'];
imagejpeg($tmp,$filename,100);

imagedestroy($src);
imagedestroy($tmp);
?>

以上是关于PHP ITwebinfo.com - 调整jpeg图像的大小的主要内容,如果未能解决你的问题,请参考以下文章

没有 Imagick 的图像调整大小并失去透明度

PHP

如何将 jp2 图像转换为 jpg 文件?

php如何将json数据写入数据库

添加php模块 imagick

从UTF-8到EUC-JP的Groovy中的字符编码转换