Array getimagesize (string $filename [, Array & $imageinfo]) to get the image size
Resource Imagecreatetruecolor (int $x _size, int $y _size) Create a new true color image
Resource Imagecreatefromjpeg (string $filename) Create a new image from a JPEG file or URL
BOOL Imagecopyresized (Resource $DST _image, resource $src _image, int $dst _x, int $dst _y, int $src _x, int $src _y, in T $dst _w, int $dst _h, int $src _w, int $src _h) copy part of the image and resize it
BOOL Imagejpeg (Resource $image [, String $filename [, int $quality]]) output images to a browser or file in JPEG format
The code is as follows:
<?php
/*
Created by <a href= "http://www.php1.cn/" >*/
File and Zoom dimensions
$imgfile = ' smp.jpg ';
$percent = 0.2;
Header (' Content-type:image/jpeg ');
List ($width, $height) = getimagesize ($imgfile);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = Imagecreatetruecolor ($newwidth, $newheight);
$source = Imagecreatefromjpeg ($imgfile);
Imagecopyresized ($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
Imagejpeg ($THUMB);
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service