I used getimagesize to get the size of the original image and then x0.5 the picture/5 Oh.
Array getimagesize (string $filename [, Array & $imageinfo])
The getimagesize () function will determine any gif,jpg,png,swf,swc,ps tutorials D,TIFF,BMP,IFF,JP2,JPX,JB2,JPC,XBM or wbmp The size of the image file and returns the size of the image as well as the file type and a height/width text string that can be used in markup in normal HTML files.
If the image specified by filename cannot be accessed or is not a valid image, GetImageSize () returns false and produces an e_warning level error
*/
Define a file
$filename = ' 1.jpg ';
$percent = 0.5;
Send header File
Header (' Content-type:image/jpeg ');
Get the size of an image
List ($width, $height) =getimagesize ($filename);
Define a new size
$new _width= $width * $percent;
$new _height= $height * $percent;
$image _p=imagecreatetruecolor ($new _width, $new _height);
/*
: int imagecreate (int x_size, int y_size);
return value: Integer
Content Description
This function is used to create an all-empty graph. The parameter x_size, Y_size is the size of the graph, in pixels (pixel).
*/
$image =imagecreatefromjpeg ($filename);
/*
Resource Imagecreatefromjpeg (string filename) imagecreatefromjpeg () returns an image identifier that represents the image obtained from the given file name. Imagecreatefromjpeg () returns an empty string on failure and outputs an error message that unfortunately appears as a broken link in the browser. To alleviate the debugging work The following example produces an error JPEG:
*/
Imagecopyresampled ($image _p, $image, 0,0,0,0, $new _width, $new _height, $width, $height);
/*
): Imagecopyresamples (), the pixel interpolation algorithm gets a smoother image edge. Good quality (but the function is slower than imagecopyresized ().) The parameters of the two functions are the same. as follows: Imagecopyresampled (DEST,SRC,DX,DY,SX,SY,DW,DH,SW,SH);
*/
Output image
Imagejpeg ($image _p, NULL, 100);
/*
Executing this code will scale the original image by 50% and output it as a new image
*/
http://www.bkjia.com/PHPjc/632993.html www.bkjia.com true http://www.bkjia.com/PHPjc/632993.html techarticle I used getimagesize to get the size of the original image and then x0.5 the picture/5 Oh. Array getimagesize (string $filename [, array $imageinfo]) the getimagesize () function will measure any ...