Image thumbnail Php / * * Image thumbnail * $ srcfile source picture, $ RATE Zoom ratio, default is half a half *, for example: ResizeImage ("Zt32.gif", ". 1"); * /
Function ResizeImage ($ 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 ($ IMG); $ srch = imageeesy ($ IMG); // destination picture width and height $ dstw = floor ($ srcw * $ rat); $ dsth = floor ($ srch * $ rat); // 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 to your browser or file Header in JPEG format; Imagejpeg ($ IM); // Release Image ImageDestroy ($ IM ImagesDestroy ($ IMG);
}?> Put the picture into the mysql database / * * Store the picture into the mysql database * # # Table structure` #
Create Table Images (Picid Int (3) Not Null Auto_INCREMENT, PICDATA Longblob Not Null, Pictext Varchar (100) Not Null Default ', Primary Key (Picid) TYPE = MyISAM;
* / if (TRIM ($ PICFile [0])! = "") {$ link = @ mysql_connect ("localhost", "root", "root"); // Connect, replace root with your specific connection name, Specific connection password replacing root if ($ link == false) {echo "