


A php that generates thumbnail code proportionally_PHP tutorial
Jul 13, 2016 am 10:45 AMA 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;
}
?>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
