Introduction: This is a detailed page of functions used to generate thumbnail images when uploading images. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325459 'rolling = 'no'>
Author/Source: keniv
Function used to generate a thumbnail when uploading an image
Practical application see http://feifei2.bjedu.gov.cn/cgi-bin/funnymovie.php
// There are many funny movies
// This function extracts the image from the source file, sets it to the specified size, and outputs it to the target file.
// Source file format: GIF, JPG, and PNG
// Target file format: JPG
// $ Srcfile: source file
// $ Dstfile: target file
// $ Dstw: Target Image Width
// $ DTH: height of the target file
Function makethumb ($ srcfile, $ dstfile, $ dstw, $ dsomething ){
$ DATA = getimagesize ($ srcfile, & $ info );
Switch ($ data [2]) {
Case 1:
$ Im = @ imagecreatefromgif ($ srcfile );
Break;
Case 2:
$ Im = @ imagecreatefromjpeg ($ srcfile );
Break;
Case 3:
$ Im = @ imagecreatefrompng ($ srcfile );
Break;
}
$ Srcw = imagesx ($ IM );
$ Srch = imagesy ($ IM );
$ Ni = imagecreate ($ dstw, $ dsomething );
Imagecopyresized ($ Ni, $ im, 0, 0, 0, $ dstw, $ dsomething, $ srcw, $ srch );
Imagejpeg ($ Ni, $ dstfile );
// If You Need to output data to the browser, change the previous sentence to imagejpeg ($ Ni );
// If you need images in other formats, you can change the last sentence.
More articles about "functions for generating thumbnail images when uploading images"
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/325459.html pageno: 14