Introduction: This is a detailed page for generating thumbnails in PHP and other scales. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 342710 'rolling = 'no'>
Function resizeimg ($ imgsrc, $ resize_width, $ resize_height, $ iscut = false) {// image type $ type = substr (strrchr ($ imgsrc ,". "), 1); // initialize the image if ($ type =" jpg ") {$ im = imagecreatefromjpeg ($ imgsrc );} if ($ type = "GIF") {$ im = imagecreatefromgif ($ imgsrc);} if ($ type = "PNG ") {$ im = imagecreatefrompng ($ imgsrc);} // target image address $ full_length = strlen ($ imgsrc); $ type_length = strlen ($ type ); $ name_length = $ full_length-$ type_length; $ name = substr ($ imgsrc, 0, $ name_length-1); $ dstimg = $ name. "_ S. ". $ type; $ width = imagesx ($ IM); $ Height = imagesy ($ IM); // ratio of the generated image // ratio of the changed image $ resize_ratio = ($ resize_width) /($ resize_height); // ratio of the actual image $ ratio = ($ width)/($ height); If ($ iscut) = 1) // cut graph {if ($ ratio >=$ resize_ratio) // height first {$ newimg = imagecreatetruecolor ($ resize_width, $ resize_height); imagecopyresampled ($ newimg, $ im, 0, 0, 0, 0, $ resize_width, $ resize_height, ($ height) * $ resize_ratio), $ height); imagejpeg ($ newimg, $ dstimg );} if ($ ratio <$ resize_ratio) // width first {$ newimg = imagecreatetruecolor ($ resize_width, $ resize_height); imagecopyresampled ($ newimg, $ im, 0, 0, 0, 0, 0, $ resize_width, $ resize_height, $ width, ($ width)/$ resize_ratio); imagejpeg ($ newimg, $ dstimg );}} else // uncut graph {if ($ ratio >=$ resize_ratio) {$ newimg = imagecreatetruecolor ($ resize_width, ($ resize_width)/$ ratio); imagecopyresampled ($ newimg, $ im, 0, 0, 0, 0, $ resize_width, ($ resize_width)/$ ratio, $ width, $ height); imagejpeg ($ newimg, $ dstimg );} if ($ ratio <$ resize_ratio) {$ newimg = imagecreatetruecolor ($ resize_height) * $ ratio, $ resize_height); imagecopyresampled ($ newimg, $ im, 0, 0, 0, 0, ($ resize_height) * $ ratio, $ resize_height, $ width, $ height); imagejpeg ($ newimg, $ dstimg) ;}} imagedestroy ($ IM );}
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/342710.html pageno: 6.