Using PHP thumbnails and clipping graphs
Api:
Resource Imagecreatetruecolor(int $width, int $height)
Magecreatetruecolor () returns an image identifier representing a black image with a size of x_size and y_size.
Whether this function is defined depends on the version of PHP and GD. From PHP 4.0.6 to 4.1.x as long as the GD module has been loaded this function has been in existence, but when the GD2 is not installed, PHP will send a fatal error and exit. In PHP 4.2.x This behavior instead of an error is issued instead of a warning. Other versions define this function only when the correct GD version is installed.
bool imagecopy(Resource $dst _im, resource $src _im, int $dst _x, int $dst _y, int $src _x, int $src _y, int $src _w, int $src _h)
Starts the coordinates in the src_im image from Src_x,src_y, with a width of src_w, and a portion of the height of Src_h copied to the Dst_im and dst_x locations in the dst_y image.
bool imagejpeg(Resource $image [, String $filename [, int $quality]])
Imagejpeg () creates a JPEG image from the image images with filename.
Ool Imagedestroy(Resource $image)
Imagedestroy () releases the memory associated with the image. Images are image identifiers returned by the image creation function, such as Imagecreatetruecolor ().
Http://www.cnblogs.com/xiaomia/archive/2010/11/13/1876191.html
At first, the Imagecopyresized method was used to reduce the image, and the actual operation revealed that the dryness point was very serious after the image was reduced. After the use of Imagecopysampled method, the method will re-sampling the image, the image is reduced to smooth processing, so that the clarity is greatly improved
List ($src _w, $src _h) =getimagesize ($src _img); Get the original size $dst_scale = $DST _h/$dst _w; Target image aspect ratio $src_scale = $src _h/$src _w; Original aspect ratio if ($src _scale>= $dst _scale) { //High $w = Intval ($src _w); $h = Intval ($dst _scale* $w); $x = 0; $y = ($src _h-$h)/3 ;} else{//over-width $h = intval ($src _h), $w = Intval ($h/$DST _scale); $x = ($src _w-$w)/2; $y = 0;} Cut $source=imagecreatefromjpeg ($src _img), $croped =imagecreatetruecolor ($w, $h) imagecopy ($croped, $source, 0,0, $x , $y, $src _w, $src _h);//Zoom $scale = $dst _w/$w; $target = Imagecreatetruecolor ($dst _w, $dst _h); $final _w = Intval ($w * $scale) ; $final _h = Intval ($h * $scale); imagecopyresampled ($target, $croped, 0,0,0,0, $final _w, $final _h, $w, $h);//Save $timestamp = time (); Imagejpeg ($target, "$timestamp. jpg"); Imagedestroy ($target);
Http://www.cnblogs.com/analyzer/articles/1267017.html
First of all, the thumbnail, it used more, the code is as follows:
In other words, the shear chart, is not to scale, but from the original image cut a small plot, compare personality. The code is as follows: