A php that generates thumbnail code proportionally_PHP tutorial

WBOY
Release: 2016-07-13 10:45:33
Original
990 people have browsed it

A php code that generates thumbnails proportionally The image in this article is the image address you want to generate. This is a PHP code that generates thumbnails proportionally. As long as you give you a picture, it can generate a picture of a specified size without deformation ekt

A PHP tutorial to generate thumbnail code proportionally

The image in this article is the image address you want to generate. This is a PHP code that generates thumbnails proportionally. As long as you give you a picture, it can generate a picture of a specified size without deformation ekt
*/

function resizeimage($image,$width,$height,$scale) {
list($imagewidth, $imageheight, $imagetype) = getimagesize($image);
$imagetype = image_type_to_mime_type($imagetype);
$newimagewidth = ceil($width * $scale);
$newimageheight = ceil($height * $scale);
$newimage = imagecreatetruecolor($newimagewidth,$newimageheight);
switch($imagetype) {
case "image/gif":
$source=imagecreatefromgif($image);
Break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
$source=imagecreatefromjpeg($image);
Break;
case "image/png":
case "image/x-png":
$source=imagecreatefrompng($image);
Break;
}
imagecopyresampled($newimage,$source,0,0,0,0,$newimagewidth,$newimageheight,$width,$height);

switch($imagetype) {
case "image/gif":
Imagegif($newimage,$image);
Break;
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
Imagejpeg($newimage,$image,90);
Break;
case "image/png":
case "image/x-png":
Imagepng($newimage,$image);
Break;
}

chmod($image, 0777);
return $image;
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633017.htmlTechArticleA php code to generate thumbnails proportionally. The image in this article is the image address you want to generate. This is A PHP code that generates thumbnails proportionally. Just give you a picture and it will generate a specified size...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!