phpif (isset ($ _ get ["]) {$ srcfile = $ _get [" filename "]; // echo $ srcfile; ResizeImage ($ srcfile, 100);}
/ * * Image Zoom * $ srcfile source image, * $ RATE Zoom ratio, default is half a half, or the specific width pixel value *, for example: ResizeImage, ". *, *, For example: ResizeImage "Zt32.gif", "250"); * Description: Put the result of the function directly in the html file IMG tag when calling * / function resizeImage ($ srcfile, $ RATE = .5) {$ size = getimagesize ($ srcfile); switch ($ size [2]) {case 1: $ img = imagecreatefromgif ($ srcfile); break; case 2: $ img = imagecreatefromjpeg ($ srcfile); break; case 3: $ img = imagecreatefrompng ($ srcfile); Break;} // Source image width and height $ srcw = imagesx; $ srch = imagesy; // destination image Width and height IF ($ size [0] < = $ RATE || $ SIZE [1] <= $} {$ DSTW = $ srcw; $ dsth = $ srch;} else {ix ($ rat <= 1) {$ dstw = floor ($ srcw * $ raate) ); $ Dsth = floor ($ srch * $ rat);} else {$ dstw = $ rat; $ rat = $ rat / $ srcw; $ dsth = floor ($ srch * $ rat);}} // echo " $ DSTW, $ DSTH, $ SRCW, $ SRCH "; // New a true color image $ IM = ImageCreatetrueColor ($ DSTW, $ DSTH); $ black = imagecolorallocate ($ IM, 255, 255, 255); ImageFilledRectangle ($ IM, 0, 0, $ DSTW, $ DSTH, $ Black; ImageCopyResized ($ IM, $ IMG, 0, 0, 0, $ DSTW, $ DSTH, $ SRCW, $ srch); // Output image in JPEG format Browser or file image JPEG ($ IM); // Release Image ImageDestroy ($ IM); ImageDestroy;}?>