This can be achieved in PHP through the [$filename="./QR/$id.jpg";$percent=0.4;list($width, $height) = getimagesize(...);] method Modify the image size, where the parameter percentage is the reduction ratio.
Recommendation: "PHP Video Tutorial"
How to change the image size in PHP
$filename = "./QR/$id.jpg"; $percent = 0.4; list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p,'./images/thumb/'.$id.'.jpg');
filename is the file name;
percent is the reduction ratio;
imagejpeg is the output saved image.
The above is the detailed content of How to modify image size in php. For more information, please follow other related articles on the PHP Chinese website!